I have a project that uses Boost.Filesystem, Boost.Test. Project contains several modules - static libs (.a) and applications. All modules successfully compiled. But I can't link compiled files into the application.
For example I try to generate simple testapp
that have main()
func and invokes functions from two other static libs.
g++ -static test.o -L/../boost/stage/lib -l:libboost_filesystem.a -l:libboost_system.a -L../BuildOutput -l:utilstest.a -l:utils.a -o testapp
For this command I have a lot of warnings. All warnings point to Boost.system of Boost.Filesystem. Warnings look like this:
/../utilstest.a(string_converter_test.o): In function `std::_Function_handler<void (boost::filesystem::path const&), string_converter()::{lambda(boost::filesystem::path const&)#2}>::_M_invoke(std::_Any_data const&, boost::filesystem::path const&)':
string_converter_test.cpp:(.text+0x1695): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, __mbstate_t> const&)'
/../utils.a(string_generator.o): In function `StringGenerator::remove(boost::filesystem::path const&)':
string_generator.cpp:(.text+0xa00): undefined reference to `boost::system::system_category()'
string_generator.cpp:(.text+0xa10): undefined reference to `boost::filesystem::detail::remove(boost::filesystem::path const&, boost::system::error_code*)'
For the app that uses Boost.Test - I also have warning about Boost.System and Boost.Filesystem, but do not have warnings about Boost.Test.
I'm sure that gcc can find Boost libs, but for some reason do link with them.
I cannot figure out what is wrong. Any ideas?
Command used to compile Boost:
./bootstrap.sh
./b2 toolset=gcc address-model=64 cxxflags="-std=c++11" define=BOOST_SYSTEM_NO_DEPRECATED stage release
Command used to compile .cpp files:
g++ -I../XXX -isystem /../boost -m64 -O3 -Wall -Wextra -MMD -std=c++11 -c YYY.cpp -o YYY.o
Ubuntu 16.04, gcc 5.4.0, boost 1.61
Solution - change order of gcc arguments: g++ -static test.o -L../BuildOutput -l:utilstest.a -l:utils.a -L/../boost/stage/lib -l:libboost_filesystem.a -l:libboost_system.a -o testapp