eclipse中的静态库链接

eclipse中的静态库链接,c,eclipse-cdt,C,Eclipse Cdt,我一直在尝试用静态库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

我一直在尝试用静态库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.**** ********为项目cppgtest构建配置调试**** ****内部生成器用于生成**** 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\u main c:/mingw/bin/./lib/gcc/mingw32/4.6.2/../../../../../../../mingw32/bin/ld.exe:找不到-lgtest\u main collect2:ld返回了1个退出状态 发生生成错误,生成已停止 所用时间:750毫秒。*** 我保留了链接器命令行patterb,因为它是eclipse
${command}${FLAGS}${OUTPUT\u FLAG}${OUTPUT\u PREFIX}${OUTPUT}${INPUTS}


我一直在用谷歌搜索来解决这个问题,我尝试了各种方法,但都没能解决问题。

正如您已经发现的,linker参数
-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.

[见我的帖子][1]。我今天解决了。[1] :是的,我按照链接中的建议将静态库添加到工作区,并在正确的位置提供静态库路径和名称(不带扩展名.a),但仍然收到相同的错误。有什么提示吗??谢谢把它放在你的项目中。确保你没有lib作为前缀,我已经有了!!实际上,在工作区中,静态库的名称应该以libXXX.a开头,我们应该在链接器设置部分包含库的名称,而不包含lib前缀和.a扩展名。谢谢你的帮助!!