链接C ++失败[未定义的参考boost :: filesystem3 ...] [英] Failed at linking C++ [undefined reference boost::filesystem3 ... ]

查看:400
本文介绍了链接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.

这篇关于链接C ++失败[未定义的参考boost :: filesystem3 ...]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆