Search code examples
c++boost-serializationbjam

Help compiling and using boost c++ libraries


I am working on a C++ project where I'd like to use boost's serialization libraries. I downloaded and installed the latest boost libraries from boost's home page.

When I tried to compile and run the one of boost's demo serialization examples, I got all sorts of errors that looked like this:

    /usr/local/include/boost/archive/detail/iserializer.hpp:173: undefined reference to `boost::archive::archive_exception::~archive_exception()'
./demo.o: In function `void boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive>::save_standard::invoke<bus_schedule::trip_info>(boost::archive::text_oarchive&, bus_schedule::trip_info const&)':
/usr/local/include/boost/archive/detail/oserializer.hpp:253: undefined reference to `boost::archive::detail::basic_oarchive::save_object(void const*, boost::archive::detail::basic_oserializer const&)'
./demo.o: In function `void boost::archive::save_access::end_preamble<boost::archive::text_oarchive>(boost::archive::text_oarchive&)':
/usr/local/include/boost/archive/detail/oserializer.hpp:83: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
./demo.o: In function `void boost::archive::detail::load_pointer_type<boost::archive::text_iarchive>::invoke<bus_route*>(boost::archive::text_iarchive&, bus_route*&)':
/usr/local/include/boost/archive/detail/iserializer.hpp:518: undefined reference to `boost::archive::detail::basic_iarchive::load_pointer(void*&, boost::archive::detail::basic_pointer_iserializer const*, boost::archive::detail::basic_pointer_iserializer const* (*)(boost::serialization::extended_type_info const&))'
./demo.o: In function `void boost::archive::detail::save_pointer_type<boost::archive::text_oarchive>::non_polymorphic::save<bus_route>(boost::archive::text_oarchive&, bus_route&)':

I am new to C++ and boost so any help would be appreciated.

Thanks


Solution

  • Thank you everyone for all your help. I finally got my problem solved, though my solution is fairly anti-climactic, and probably not that informative.

    I had tried to install the boost libraries manually, by downloading them from boost's website directly, and found that all the libraries had been installed in /usr/local/lib, and /usr/local/include/boost/ . After repeatedly running into my original errors, I decided to see if the Synaptic Package Manager could do a 'better' job of installing the boost libraries. I selected 'libboost1.40-all-dev' to install everything, but still nothing was working.

    Finally, I decided to start fresh so manually deleted the boost/ directory in /usr/local/include, and I deleted all the libboost files in /usr/local/lib. I then marked all the boost libraries for complete removal to remove everything. Once all the boost libraries were uninstalled, I went back to the Synaptic Package Manager, selected 'libboost1.40-all-dev' one more time.

    I am not sure what exactly changed when I re-installed the libraries again, but everything started to work again. I first tested from the command line, and tried to compile the demo.cpp from boost's website one more time with the following command:

    g++ demo.cpp -lboost_serialization
    

    and it compiled immediately. Running the executable displayed exactly the results I was looking for. Furthermore, I moved the file back into my Eclipse project, added 'boost_serialization' to the Linker libraries, and tried to build the project. Everything worked perfectly again, as I could build the project and run the example code.

    I don't really have an explanation for why this fixed my problem, but to anyone else experiencing similar problems, the best advice I can give is to NOT install the boost libraries directly, but rather have the Synaptic Package Manager handle everything.

    Thanks again everyone, you've been extremely helpful.