4
votes

properties/C/C++ Build/Settings GCC C++ Linker/Libraries

Under libraries(-I) I have libbost_system libbost_filesystem ... and under Library search path(-L) I have /home/etobkru/boost_1_43_0/boostBinaries/lib

but when I compile I get g++ -L/home/etobkru/boost_1_43_0/boostBinaries/lib/ -o"searchDirs" ./main.o -llibboost_system -llibboost_filesystem -llibboost_regex /usr/lib/gcc/i586-suse-linux/4.1.2/../../../../i586-suse-linux/bin/ld: cannot find -llibboost_system

I have tried with libbost_system.so and libbost_system.a but i get the same error. What am I doing wrong and why cant eclipse find the files. Because they are there?

4

4 Answers

9
votes

You don't need the "lib" part in the name. Just link with

-lboost_system -lboost_filesystem -lboost_regex
2
votes

I think this is similar to /usr/bin/ld: cannot find -llibeststring.a

Did you try -lboost_system? The -l option doesn't expect the leading lib or the trailing .a or .so.

1
votes

I know it's a little after the fact, but you can try -l:libbost_system.so and it will look for a library with exactly that name.

1
votes

Actually after much frustration I decided to read the man page for 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.

since my specific library was something along the lines of myfoobar.dll nothing worked until I realized I wanted ld to use the actual filename. As others have posted with screenshots how to add the library to the linker all I needed to do was change 'myfoobar' in the field to ':myfoobar.dll' and it worked fine.

You should use the ':' to get really specific on the filename to search for and stay away from the default file name formatting that is expected without it. Hope this eases frustration.

Krusty,