开发者

Problem linking with Boost.Filesystem

开发者 https://www.devze.com 2023-02-09 14:27 出处:网络
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:

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开发者_StackOverflow::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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消