-1
#include <boost/serialization/vector.hpp>

template<class Archive>
void ScenarioResult::serialize(Archive & ar, const unsigned int version)
{
                ar & scenario; 
}

-lboost_serialization is included in the linker options

In function serialize<boost::mpi::packed_oarchive, ScenarioResult>': /people/v/boost_1_59_0/boost/serialization/access.hpp:116: undefined reference tovoid ScenarioResult::serialize(boost::mpi::packed_oarchive&, unsigned int)' Integration.o: In function serialize<boost::mpi::packed_iarchive, ScenarioResult>': /people/v/boost_1_59_0/boost/serialization/access.hpp:116: undefined reference tovoid ScenarioResult::serialize(boost::mpi::packed_iarchive&, unsigned int)' collect2: error: ld returned 1 exit status

Tims
  • 627
  • 7
  • 19

1 Answers1

5

Actually, an edit to the question would be nice, but, I think I have an idea bout what going on : It looks like you are trying to separately compile a function template.

This meaning that you are doing the following :

g++ ScenarioResult.cpp -lboost_serialization

which is throwing the error.

ScenarioResult::serialize is a template function, meaning that it gets instantiated on the basis of the types of the template parameters that get passed to is. So, when compiling, the compiler doesn't know exactly the type, thus cannot generate the code.

A quick fix would be to move the implementation of your serialize method into the header file of the class. Or, explicitly instansiate it in the cpp file as the following :

void ScenarioResult::serialize<boost::archive::text_oarchive>(boost::archive::text_oarchive &ar, const unsigned int);
Vtik
  • 3,073
  • 2
  • 23
  • 38