Linking a static library in eclipse

I am trying to create my C project using the Gtest static library ( gtest_main.a ). I have included IDE information about the library file and the corresponding path in the linker section, but I still get 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 saved the linkter linker command line as it is by default present in eclipse ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

I searched for search queries to solve the problem, and I tried various methods that I come up with during the search, but could not solve the problem.

+4
source share
1 answer

As you already discovered, the linker argument -lName forces the linker to look for the library path for libName.a

For more information, see the ld man page on your system - my indicates:

  -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. 
+2
source

All Articles