views:

594

answers:

2

I've been banging my head fruitlessly against the wall attempting to include boost's thread functionality in my Eclipse C++ project on Ubuntu.

Steps so far:

Download boost from boost.org

./configure --with-libraries=system,thread
make
sudo make install

sudo ldconfig -v

In the eclipse project, set the include directory to:

/usr/local/include/boost-1_38/

In the linker set the library(-l) to "boost_thread"

Set the search path (-L) to

/usr/local/lib

Linker runs, returns with ld error

/usr/bin/ld: cannot find -lboost_thread

as follows:

Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o"boostHello3"  ./src/boostHello3.o   -lboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status

Here are relevant entries from /usr/local/lib:

libboost_system-gcc43-mt-1_38.a
libboost_system-gcc43-mt-1_38.so
libboost_system-gcc43-mt-1_38.so.1.38.0
libboost_system-gcc43-mt.a
libboost_system-gcc43-mt.so

libboost_thread-gcc43-mt-1_38.a
libboost_thread-gcc43-mt-1_38.so
libboost_thread-gcc43-mt-1_38.so.1.38.0
libboost_thread-gcc43-mt.a
libboost_thread-gcc43-mt.so

Here are the contents of /etc/ld.so.conf

include /etc/ld.so.conf.d/*.conf
/usr/local/lib

How is the linker missing this?

+1  A: 

Your linker line should be saying -lboost_thread-gcc43-mt-1_38.

Dimitri Tcaciuc
Thanks, Dimitri!
Jack BeNimble
+2  A: 

Well, the linker tries to find a library called "libboost_thread.a" (or "libboost_thread.so") in its search path, which you apparently don't have. Either create an appropriate link, or use "-lboost_thread-gcc43-mt"

I tried -lboost_thread-gcc43-mt", also, and it worked. But why? There is no symlink set up for that specific string. Or does it drop the ".o" and ".a" reference and take the name for whichever type of library it needs?
Jack BeNimble