Boost linkage error in Eclipse

Boost linkage error in Eclipse

等风来 发布于 2021-11-30 字数 1475 浏览 675 回复 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?

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

扫码加入群聊

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的那么颓废 2022-06-07 2 楼

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

笑咖 2022-06-07 1 楼

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"