I am trying to build a demo from the Boost::Serialization page:
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
class gps_position
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & degrees;
ar & minutes;
ar & seconds;
}
int degrees;
int minutes;
float seconds;
public:
gps_position(){};
gps_position(int d, int m, float s) :
degrees(d), minutes(m), seconds(s)
{}
};
int main() {
std::ofstream ofs("filename");
const gps_position g(35, 59, 24.567f);
{
boost::archive::text_oarchive oa(ofs);
oa << g;
}
return 0;
}
But I am getting the following linker errors:
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
(null): "boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int)", referenced from:
(null): "boost::archive::basic_text_oprimitive<std::__1::basic_ostream<char, std::__1::char_traits<char> > >::~basic_text_oprimitive()", referenced from:
(null): Linker command failed with exit code 1 (use -v to see invocation)
I am using boost 1.53.0 in Mountain Lion and XCode 4.6.2.
I have added the path to the headers (Header Search Paths) and libraries (Library Search Paths) and also added libboost_serialization.dylib in Link Binary with Libraries.
Searching in other threads my problems seems to be that I haven't told the compiler about the static library libboost_serialization.a. How do I do this ? (If this is my problem). I tried added to the Other Linker Flags like so: -lboost_serialization with no result.
Anyone else experienced this problem ?
Thnaks in advance.
Have you got some warnings like this ?
ignoring file your _lib_file_name , file was built for unsupported file format (blah blah blah) which is not the architecture being linked
It you have, try to build boost with a proper configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.