未定义对`boost::thread的引用

undefined reference to `boost::thread

本文关键字:thread 引用 boost 未定义      更新时间:2023-10-16

我正在尝试将libgetfiles.so链接到main.cpp。我运行了以下命令:

sudo g++ main.cpp -L/ubuntu/test -lgetfiles -L/usr/local/lib/ -lboost_thread

它给了我以下错误:

/ubuntu/test/libgetfiles.so: undefined reference to'boost::thread::start_thread_noexcept()' /ubuntu/test/libgetfiles.so: undefined reference to 'boost::thread::join_noexcept()' /ubuntu/test/libgetfiles.so: undefined reference to 'boost::system::system_category()' /ubuntu/test/libgetfiles.so: undefined reference to 'boost::system::generic_category()'

我该如何解决这些问题?

我也尝试过卸载和重新安装提升库。我还尝试了以下命令:

g++ main.cpp -L/ubuntu/test -lgetfiles -L/usr/local/lib/ -lboost_thread-mt

他们两个都不适合我。

如果手动构建并安装boost(即特定版本),则应检查/usr/lib中是否已安装libboost all-dev包。尝试rm /usr/lib/libboost* && rm -r /usr/include/boost,然后重新构建。