与 Boost.Filesystem 链接时出现问题
我正在尝试使用 boost::filesystem 中的函数来更改我当前的工作目录(并在必要时创建它)。我收到链接错误:
SBDir.cpp:(.text+0x23): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x2f): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x3b): undefined reference to `boost::system::system_category()'
但是我正在链接到 boost 库??!?我使用以下内容:
-lboost_system -lboost_system-mt -lboost_filesystem -lboost_filesystem-mt
我知道它可以找到它们,因为使用 -Wl, -t
我得到:
-lboost_system (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system.so)
-lboost_system-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system-mt.so)
-lboost_filesystem (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem.so)
-lboost_filesystem-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem-mt.so)
FWIW:我正在使用 gcc Ubuntu 4.4.3-4ubuntu54.4.3
。
I am trying to use the functions from boost::filesystem to change my current working directory (and create it if necessary). I am getting linking errors:
SBDir.cpp:(.text+0x23): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x2f): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x3b): undefined reference to `boost::system::system_category()'
But I am linking against the boost libraries??!? I use the following:
-lboost_system -lboost_system-mt -lboost_filesystem -lboost_filesystem-mt
And I know it can find them because with -Wl, -t
I get:
-lboost_system (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system.so)
-lboost_system-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system-mt.so)
-lboost_filesystem (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem.so)
-lboost_filesystem-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem-mt.so)
FWIW: I'm using gcc Ubuntu 4.4.3-4ubuntu54.4.3
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 boost 1.46(Ubuntu 11.10 的标准)中遇到了同样的错误消息,我必须添加 -lboost_system ,这是我在 11.04 和 boost 1.42 中不需要的。它没有回答您的问题,但通过谷歌搜索错误消息来到这里的其他人可能会感兴趣。
I had this same error message with boost 1.46 (standard with Ubuntu 11.10) and I had to add -lboost_system which I didn't need in 11.04 and boost 1.42. It doesn't answer your question but possibly of interest to others brought here by googling the error message.
所以我无法弄清楚出了什么问题——所以我尝试卸载 Ubuntu boost 包并从头开始构建它。我升级到 1.45.0 &现在一切都链接起来。不确定这是否是版本特定的问题,但如果我稍后了解更多信息,我会回来更新。
So I couldn't figure out what went wrong -- so I tried un-installing the Ubuntu boost package and building it from scratch. I upgraded to 1.45.0 & now everything links. Not sure whether this was a version specific problem or not, but if I learn more later I'll come back and update.