trahul
trahul

Reputation: 21

compilation error in boost serialization, undefined reference

I have included these header files.

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/vector.hpp>

and then I have two lines:

ofstream s_dict("save_dict.archive");
boost::archive::text_oarchive oa_dict(s_dict);

while compiling:

g++ -lboost_serialization -lboost_system coord.cpp

it throws a long list of errors out of which the first error is:

/tmp/ccRMDC8f.o: In function boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int)': coord.cpp:(.text._ZN5boost7archive13text_oarchiveC2ERSoj[_ZN5boost7archive13text_oarchiveC5ERSoj]+0x25): undefined reference toboost::archive::text_oarchive_impl::text_oarchive_impl(std::ostream&, unsigned int)'

It is getting undefined reference to boost functions.

Upvotes: 2

Views: 1086

Answers (1)

user7860670
user7860670

Reputation: 37468

Try reordering g++ coord.cpp -lboost_serialization -lboost_system

Upvotes: 1

Related Questions