I'm trying to build boost (1.65) on linux with C++11 support to link with my other project (also compiled with C++11 support).
However, I get this kind of error (which seems to happen because my boost is not compiled with c++11):
undefined reference to `boost::filesystem::detail::current_path(boost::system::error_code*)'
data_parser.cc:(.text+0xf15): undefined reference to `boost::filesystem::absolute(boost::filesystem::path const&, boost::filesystem::path const&)'
data_parser.cc:(.text+0x142e): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
data_parser.cc:(.text+0x1790): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
Here is my command line:
./b2 --prefix=boost-install --with-filesystem --with-system --with-program_options --with-thread link=static variant=release cxxflags='-std=c++11' install
But I noticed during compilation if I compile without any --with- (so with all libraries), I can see this line:
- C++11 mutex : yes
and some other lines related to c++11, however as soon as I add a --with- (e.g. --with-thread), all lines relative to c++11 disappear.
I also tried to add #define BOOST_NO_CXX11_SCOPED_ENUMS
around #include <boost/filesystem.hpp>
but it doesn't change anything.
I have no clue what is going on here, if someone can help me.
Thank you.
Update: Here is the command of the linking command:
/usr/bin/c++ -std=c++11 -O3 -DNDEBUG CMakeFiles/MyProject.dir/MyProject.cc.o -o MyProject -L/home/whiteshadow/code/MyProject-build/deps/boost-install/lib -L/home/whiteshadow/code/MyProject-build/deps/zlib-install/lib -L/home/whiteshadow/code/MyProject-build/deps/nifticlib-install/lib -Wl,-rpath,/home/whiteshadow/code/MyProject-build/deps/boost-install/lib:/home/whiteshadow/code/MyProject-build/deps/zlib-install/lib:/home/whiteshadow/code/MyProject-build/deps/nifticlib-install/lib: -rdynamic ../deps/zlib-install/lib/libz.a ../deps/nifticlib-install/lib/libznz.a ../deps/nifticlib-install/lib/libnifticdf.a ../deps/nifticlib-install/lib/libniftiio.a -lboost_filesystem -lboost_system -lboost_thread -lboost_program_options DataStructure/libDataStructure.a FileHandler/libFileHandler.a Parser/libParser.a Tools/libTools.a -lpthread FileHandler/libFileHandler.a FileHandler/libFileHandler.a Tools/libTools.a DataStructure/libDataStructure.a
I don't think it comes from a mis-linking issue, because if I remove -lboost_filesystem I have much more linking errors. Here I only have 7, related to only 3 functions (boost::filesystem::detail::status, boost::filesystem::detail::current_path and boost::filesystem::absolute).
Also, in libboost_filesystem.a, I'm able to find symbols for these 3 functions:
(boost::filesystem::detail::status)
00000000000026d0 T _ZN5boost10filesystem6detail6statusERKNS0_4pathEPNS_6system10error_codeE
(boost::filesystem::detail::current_path)
0000000000000c90 T _ZN5boost10filesystem6detail12current_pathEPNS_6system10error_codeE
(boost::filesystem::absolute)
0000000000001100 T _ZN5boost10filesystem8absoluteERKNS0_4pathES3_