首页 文章

eclipse中的静态库链接

提问于
浏览
4

我一直在尝试使用静态库Gtest( gtest_main.a )框架构建我的C项目 . 我已经在IDE的链接器部分中包含了有关库文件和相应路径的信息,但我仍然收到以下错误:

******** Build of configuration Debug for project CPP_GTEST ****
**** Internal Builder is used for build               ****
g++ -LC:/UT_automation_tools/CPP_GTEST/lib -o CPP_GTEST.exe ut_src\ut_asd.o mock_lib\sgn\sgn_asd.o asd\asd.o -lgtest_main
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lgtest_main
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 750  ms.****

我保留了链接器命令行patterb,因为它是eclipse中存在的默认值 ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

我一直在谷歌搜索解决这个问题,我尝试了各种方法,我在谷歌搜索时遇到但无法解决问题 .

1 回答

  • 2

    正如您已经发现的那样,链接器参数 -lName 使链接器在库路径中搜索 libName.a

    有关详细信息,请参阅系统上ld的手册页 - mine指定:

    -l namespec
       --library=namespec
           Add the archive or object file specified by namespec to the list of files to link.  This option
           may be used any number of times.  If namespec is of the form :filename, ld will search the
           library path for a file called filename, otherwise it will search the library path for a file
           called libnamespec.a.
    

相关问题