eclipse中的静态库链接

Thi*_*iru 5 c eclipse-cdt

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

******** 项目 CPP_GTEST 配置调试的构建 ****
**** 内部构建器用于构建 ****
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:找不到-lgtest_main
collect2: ld 返回 1 个退出状态
发生构建错误,构建已停止
消耗时间:750 ms.****  

我保留了链接器命令行模式,因为它是 eclipse 中的默认设置 ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

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

aus*_*ton 2

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

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

  -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.
Run Code Online (Sandbox Code Playgroud)