I've tested the following code in a console application, and it compiles just fine. However, when I copy it to a header to include in a larger project, I get 77 link errors, all related to boost.
If I comment out the line in red, everything compiles just fine without any errors.
#include <iostream>
#include <fstream>
// include headers that implement a archive in simple text format
#include <boost/regex.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/base_object.hpp>
class LinRegData
{
friend class boost::serialization::access;
// When the class Archive corresponds to an output archive, the
// & operator is defined similar to <<. Likewise, when the class Archive
// is a type of input archive the & operator is defined similar to >>.
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & BofVC;
}
public:
LinRegData(){}
~LinRegData(){}
double BofVC;
void PrintSelf()
{
// create and open a character archive for output
std::ofstream ofs("C:\\Users\\J\\Documents\\notes\\TradeParams.dat");
// save data to archive
{
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa << *this;
// archive and stream closed when destructors are called
}
}
};
In both projects I have entered the boost directory under "Addition Include Directories" and added the boost library folder under "Additional Library Directories."
Any help would be greatly appreciated. I don't really know where to start.
The first of 77 errors reads " error LNK2019: unresolved external symbol "protected: __cdecl boost::archive::detail::basic_oserializer::basic_oserializer(class boost::serialization::extended_type_info const &)" (??0basic_oserializer@detail@archive@boost@@IEAA@AEBVextended_type_info@serialization@3@@Z) referenced in function "public: __cdecl boost::archive::detail::oserializer<class boost::archive::text_oarchive,class Params::LinRegData>::oserializer<class boost::archive::text_oarchive,class Params::LinRegData>(void)" (??0?$oserializer@Vtext_oarchive@archive@boost@@VLinRegData@Params@@@detail@archive@boost@@QEAA@XZ)"