When I type make
I get:
Linking CXX executable ../../bin/MyProgram
../../lib/libMP.a(MPL.cpp.o): In function `_GLOBAL__sub_I_mult_fmm2':
MPL.cpp:(.text.startup+0x15): undefined reference to `boost::system::generic_category()'
MPL.cpp:(.text.startup+0x1a): undefined reference to `boost::system::generic_category()'
MPL.cpp:(.text.startup+0x1f): undefined reference to `boost::system::system_category()'
../../lib/libThing.a(vases.cpp.o): In function `_GLOBAL__sub_I__ZN9Thing6VasesC2ERKN3Two9DimensionENS1_8DataTypeE':
Vases.cpp:(.text.startup+0x15): undefined reference to `boost::system::generic_category()'
Vases.cpp:(.text.startup+0x1a): undefined reference to `boost::system::generic_category()'
Vases.cpp:(.text.startup+0x1f): undefined reference to `boost::system::system_category()'
...
../../lib/libThing.a(HDF5_IO.cpp.o): In function `Thing::HDF5_IO::createVolumeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Two::GenericBoundingBox<double> const&, Two::Dimension const&, std::vector<Two::DataType, std::allocator<Two::DataType> > const&, unsigned int, unsigned int, double, double) const':
HDF5_IO.cpp:(.text+0x79c5): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
../../lib/libThing.a(HDF5_IO.cpp.o): In function `Thing::HDF5_IO::writeVolumeFile(Thing::Volume const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int, unsigned long, unsigned long, unsigned long, bool) const':
HDF5_IO.cpp:(.text+0x97d1): undefined reference to `boost::thread::start_thread_noexcept()'
HDF5_IO.cpp:(.text+0x9b77): undefined reference to `boost::thread::join_noexcept()'
HDF5_IO.cpp:(.text+0x9fbb): undefined reference to `boost::thread::join_noexcept()'
...
and my link.txt
file looks like
/usr/bin/g++ -O3 -O3 -DNDEBUG CMakeFiles/MyProject.dir/main.cpp.o
-o ../../bin/MyProject -L/home/myname/Desktop/MyProject/build/lib -rdynamic -lboost_thread-mt -lboost_date_time-mt -lboost_regex
-lboost_filesystem-mt -lboost_program_options-mt ../../lib/libfftw3.a -lxcb -lXau -lXext -lX11 -lpetsc -lmpich -lmpl -lrt ../../lib/libflapack.a
-lgfortran ../../lib/libfblas.a -lgfortran ../../lib/libMyProjectAPI.a -lfftw3 -lGLU -lGL -lpthread ../../lib/libfftw3.a -lxcb -lXau -lX11 -lpetsc -lmpich -lmpl -lrt
../../lib/libflapack.a -lgfortran ../../lib/libfblas.a -lgfortran ../../lib/libfblas.a -lpthread -lboost_thread-mt -lboost_date_time-mt -lboost_regex
-lboost_filesystem-mt -lboost_system-mt -lboost_program_options-mt /home/myname/anaconda2/lib/libhdf5.so /home/myname/anaconda2/lib/libhdf5_hl.so
-lrt /home/myname/anaconda2/lib/libz.so -ldl -lm /home/myname/anaconda2/lib/libhdf5_cpp.so
/home/myname/anaconda2/lib/libhdf5_hl_cpp.so /home/myname/anaconda2/lib/libhdf5.so /home/myname/anaconda2/lib/libhdf5_hl.so -lrt /home/myname/anaconda2/lib/libz.so
-ldl -lm /home/myname/anaconda2/lib/libhdf5_cpp.so /home/myname/anaconda2/lib/libhdf5_hl_cpp.so -Wl,-rpath,/home/myname/Desktop/MyProject/build/lib:/home/myname/anaconda2/lib
Anyone know how to solve this? If I replace -lboost_system-mt
with ../../lib/libboost_system-mt.a
then I get the same error. And I see that in /home/myname/Desktop/MyProject/build/lib
that libboost_system-mt.a
clearly exists, so removing the -mt
is not the problem.
I think the problem is because I'm trying to link the executable against libraries built with another compiler. I'm using g++ 5.2 and boost is already installed in usr/include
. The program code I'm using has those libboost files in /home/myname/Desktop/MyProject/build/lib
. I got this code to work properly on an original computer, but am now having these linker errors on my new computer. That original computer used g++ on I think version 4.8
I already installed libboost-system-dev
on my new computer and it says I already have the latest version. Same when I try to install libboost-system-dev
. However, locate libboost_system-mt.a
shows that libboost_system-mt.a
is not in usr/lib
but only in /home/myname/Desktop/MyProject/build/lib