Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static library linking in eclipse

Tags:

c

eclipse-cdt

I have been trying to build my C project with a static library Gtest (gtest_main.a) framework. 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:

******** 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}

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.

like image 405
Thiru Avatar asked Nov 03 '22 19:11

Thiru


1 Answers

As you have already discovered, the linker argument -lName causes the linker to search the library path for libName.a

See man page for ld on your system for more info - mine specifies:

  -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.
like image 147
austinmarton Avatar answered Nov 09 '22 17:11

austinmarton