Again Boost linking error

Mahmood Naderan via gcc-help gcc-help@gcc.gnu.org
Wed Nov 15 15:47:00 GMT 2017


Hi,
I hope that Jonathan Wakely see this post…

Previously I asked about an undefined reference error for Boost
(https://gcc.gnu.org/ml/gcc-help/2017-10/msg00101.html).
At that time, I finally managed to solve that by using gcc-4.5 and not gcc 4.6.

 

Now, I *must* port the code and for this purpose I am using gcc 5.4 on
Ubuntu 16.04 with boost 1.60.

 
I am getting the same linking error and it is really a pain.
I have fixed many errors related to the old code, but really don’t
know what to do with this one!

 

At the linking stage, if I use

-L/home/mahmood/boost_1_60_0/lib -lboost_system -lboost_filesystem

Or remove one or two library names, I get the same error and that is very weird.

 

Please see the full commands below

 

$ g++ -fPIC -W -Wall -Wimplicit -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wmultichar -Wtrigraphs -Wpointer-arith -Wcast-align -Wreturn-type -Wno-unused-function   -m64 -fno-strict-aliasing -I/home/mahmood/boost_1_60_0  -I. -I/use/local/cuda-8.0/include -I/home/mahmood/NVIDIA_CUDA-8.0_Samples/common/inc -DUNIX -O2  -o obj/x86_64/release/aescuda.cpp.o -c aescuda.cpp
cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++
In file included from /home/mahmood/boost_1_60_0/boost/filesystem/path_traits.hpp:23:0,
                 from /home/mahmood/boost_1_60_0/boost/filesystem/path.hpp:25,
                 from /home/mahmood/boost_1_60_0/boost/filesystem/operations.hpp:25,
                 from aesCudaUtils.h:27,
                 from aescuda.cpp:28:
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:221:36: warning: ‘boost::system::posix_category’ defined but not used [-Wunused-variable]
     static const error_category &  posix_category = generic_category();
                                    ^
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:222:36: warning: ‘boost::system::errno_ecat’ defined but not used [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
                                    ^
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:223:36: warning: ‘boost::system::native_ecat’ defined but not used [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();
                                    ^


$ g++ -fPIC -W -Wall -Wimplicit -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wmultichar -Wtrigraphs -Wpointer-arith -Wcast-align -Wreturn-type -Wno-unused-function   -m64 -fno-strict-aliasing -I/home/mahmood/boost_1_60_0  -I. -I/use/local/cuda-8.0/include -I/home/mahmood/NVIDIA_CUDA-8.0_Samples/common/inc -DUNIX -O2  -o obj/x86_64/release/aesCudaUtils.cpp.o -c aesCudaUtils.cpp
cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++
In file included from /home/mahmood/boost_1_60_0/boost/filesystem/path_traits.hpp:23:0,
                 from /home/mahmood/boost_1_60_0/boost/filesystem/path.hpp:25,
                 from /home/mahmood/boost_1_60_0/boost/filesystem/operations.hpp:25,
                 from aesCudaUtils.h:27,
                 from aesCudaUtils.cpp:27:
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:221:36: warning: ‘boost::system::posix_category’ defined but not used [-Wunused-variable]
     static const error_category &  posix_category = generic_category();
                                    ^
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:222:36: warning: ‘boost::system::errno_ecat’ defined but not used [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
                                    ^
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:223:36: warning: ‘boost::system::native_ecat’ defined but not used [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();
                                    ^
 

$ g++ -fPIC -L/home/mahmood/boost_1_60_0/lib -lboost_system -lboost_filesystem   -m64 -o ./bin/release/AES    obj/x86_64/release/aescuda.cpp.o obj/x86_64/release/aesCudaUtils.cpp.o  obj/x86_64/release/aesHost.cu.o -L/usr/local/cuda-8.0/lib64   -lcudart
obj/x86_64/release/aescuda.cpp.o: In function `_GLOBAL__sub_I_aescuda.cpp':
aescuda.cpp:(.text.startup+0x61b): undefined reference to `boost::system::generic_category()'
aescuda.cpp:(.text.startup+0x620): undefined reference to `boost::system::generic_category()'
aescuda.cpp:(.text.startup+0x629): undefined reference to `boost::system::system_category()'
obj/x86_64/release/aesCudaUtils.cpp.o: In function `getFileSize(boost::filesystem::path&)':
aesCudaUtils..cpp:(.text+0xf96): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
aesCudaUtils.cpp:(.text+0xfa6): undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
obj/x86_64/release/aesCudaUtils.cpp.o: In function `readFromFileNotForm(boost::filesystem::path&, char*, unsigned int)':
aesCudaUtils.cpp:(.text+0x10e9): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
obj/x86_64/release/aesCudaUtils.cpp.o: In function `readFromFileForm(boost::filesystem::path&, std::vector<unsigned int, std::allocator<unsigned int> >&)':
aesCudaUtils.cpp:(.text+0x1543): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
obj/x86_64/release/aesCudaUtils.cpp.o: In function `initAesCuda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, unsigned int)':
aesCudaUtils.cpp:(.text+0x1fc7): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
aesCudaUtils.cpp:(.text+0x1fe1): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
obj/x86_64/release/aesCudaUtils.cpp.o: In function `_GLOBAL__sub_I_aesCudaUtils.cpp':
aesCudaUtils.cpp:(.text.startup+0x5): undefined reference to `boost::system::generic_category()'
aesCudaUtils.cpp:(.text.startup+0xa): undefined reference to `boost::system::generic_category()'
aesCudaUtils.cpp:(.text.startup+0xf): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

  

I think maybe, a switch in the g++ command causes such error.
As I greped generic_category() in the boost code, I got

 

$ grep -r generic_category /home/mahmood/boost_1_60_0/boost/system/
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    inline const error_category &  generic_category() BOOST_SYSTEM_NOEXCEPT;
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    BOOST_SYSTEM_DECL const error_category &  generic_category() BOOST_SYSTEM_NOEXCEPT;
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    inline const error_category &  get_generic_category() { return generic_category(); }
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    inline const error_category &  get_posix_category() { return generic_category(); }
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    static const error_category &  posix_category = generic_category();
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:    static const error_category &  errno_ecat     = generic_category();
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:      error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:        m_cat = &generic_category();
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:        { return error_code( e, generic_category() ); }
/home/mahmood/boost_1_60_0/boost/system/error_code.hpp:        { return error_condition( e, generic_category() ); }
/home/mahmood/boost_1_60_0/boost/system/detail/error_code.ipp:    return generic_category().message( ev );
/home/mahmood/boost_1_60_0/boost/system/detail/error_code.ipp:    BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
/home/mahmood/boost_1_60_0/boost/system/detail/error_code.ipp:      static const generic_error_category generic_category_const;
/home/mahmood/boost_1_60_0/boost/system/detail/error_code.ipp:      return generic_category_const;

 

As you can see, there are inline statements, so I am suspicious
about wrong compiler options. But I am not so expert to confirm that.
Any idea?



Regards,
Mahmood



More information about the Gcc-help mailing list