链接C ++失败[未定义的参考boost :: filesystem3 ...]
我在编译工作时遇到了一些麻烦,我在g++
上使用Ubuntu.我收到很多这样的消息:
I'm having some trouble compiling my work, I'm using Ubuntu with g++
. I get a lot of these messages:
undefined reference to `boost::filesystem3::directory_entry::m_get_status(boost::system::error_code*) const'
undefined reference to `boost::filesystem3::path::extension() const'
undefined reference to `boost::filesystem3::path::filename() const'
undefined reference to `boost::filesystem3::path::filename() const'
(等...)
我已经搜索并找到了很多答案,但是这些答案都不适合我.
I've searched and found many answers but none of those work for me.
-lboost_system (/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libboost_system.so)
-lboost_filesystem (/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libboost_filesystem.so)
链接时显示了这两个库,我猜该错误与第二个库有关.
When linking it shows those two libraries, I'm guessing the error is related to the second one.
hax@lap:~$ locate libboost_filesystem.so
/home/hax/boost_1_47_0/bin.v2/libs/filesystem/build/gcc-4.4.5/release/threading-multi/libboost_filesystem.so.1.47.0
/home/hax/boost_1_47_0/stage/lib/libboost_filesystem.so
/home/hax/boost_1_47_0/stage/lib/libboost_filesystem.so.1.47.0
/usr/lib/libboost_filesystem.so
/usr/lib/libboost_filesystem.so.1.42.0
/usr/local/lib/libboost_filesystem.so
/usr/local/lib/libboost_filesystem.so.1.47.0
这是我的生成文件上的相关行:
This is the related line on my makefile:
-L. -L../bncsutil/src/bncsutil/ -L../StormLib/stormlib/ -L../boost/lib/ -lbncsutil -lpthread -ldl -lz -lStorm -lmysqlclient_r -lboost_date_time -lboost_thread -lboost_system -lboost_filesystem -Wl -t
我尝试用-L指向我看到filesystem.so的几个不同位置,但是它不起作用!
I tried pointing with -L several different places where I saw filesystem.so was located but it didn't work!
有人可以在这些行中看到问题吗?如果您需要我放入一些额外的数据,我会做的,我没看到问题:(
Can anyone see the problem in those lines? If you need me to put some extra data I'll do it, I'm not seeing the problem :(
它似乎试图链接到可能不包含这些符号的1.42.0版本.您可以删除1.42.0版本,运行ldconfig,然后再次尝试运气.
It almost looks like it's trying to link to the 1.42.0 version which may not contain those symbols. You could remove the 1.42.0 version, run ldconfig, and try your luck again.