简体   繁体   English

eclipse中的静态库链接

[英]Static library linking in eclipse

I have been trying to build my C project with a static library Gtest ( gtest_main.a ) framework. 我一直在尝试使用静态库Gtest( gtest_main.a )框架来构建C项目。 I have included in linker section of the IDE information about the library file and respective path but I am still getting the following error: 我已在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.****

I've kept the linker command line patterb as it is default which was present in eclipse ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} 我保留了链接器命令行模式,因为它是默认的,出现在Eclipse ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

I have been googling to solve the issue and i have tried various methods which i come through while googling but didn't able to solve the problem. 我一直在使用Google搜索来解决问题,并且尝试了各种在搜索时遇到的方法,但无法解决问题。

As you have already discovered, the linker argument -lName causes the linker to search the library path for libName.a 您已经发现,链接器参数-lName使链接器在库路径中搜索libName.a

See man page for ld on your system for more info - mine specifies: 有关更多信息,请参见系统上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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM