Original Post
I'm trying to use the Boost Serialization class, but I just can't get it to work, not my code, not their code, nor any other code I've tried online. I'm pretty sure I built it right, I spent a while figuring it out and built it all. I tried my usual Google searching for any help, but haven't been able to come up with anything. I am highly disappointed with Boost right now, everyone seems to reccomend it, yet I have not found a single tutorial/example on their site that works as is. Anyways, I'm about to just do it all myself but wanted to see if the problem was me or just Boost in general, I am quite disappointed right now. Errors: Code: Oh yea, I even tried to use their entire example but it did not work either. I'm using VS 7.1/C++ and did the build of boost myself following their guide. [sad] Any ideas? I'd appreciate any help before I give up on this. Thanks for your time. [Edited by - Drew_Benton on March 9, 2006 6:00:39 PM]
------ Build started: Project: ProjectC, Configuration: Debug Win32 ------
Compiling...
Main.cpp
c:\Boost\include\boost\archive\detail\oserializer.hpp(131) : error C2027: use of undefined type 'boost::serialization::extended_type_info_null<T>'
with
[
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(131) : see reference to class template instantiation 'boost::serialization::extended_type_info_null<T>' being compiled
with
[
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(128) : while compiling class-template member function 'bool boost::archive::detail::oserializer<Archive,T>::is_polymorphic(void) const'
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(264) : see reference to class template instantiation 'boost::archive::detail::oserializer<Archive,T>' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(263) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive &,const Engine &)'
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(322) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(310) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive &,const Engine &)'
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(536) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=Engine
]
c:\Boost\include\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const Engine
]
c:\Boost\include\boost\archive\detail\interface_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const Engine
]
c:\Documents and Settings\Drew Benton\My Documents\Visual Studio Projects\ProjectC\Main.cpp(65) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<const Engine>(T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const Engine
]
c:\Boost\include\boost\archive\detail\oserializer.hpp(131) : error C2146: syntax error : missing ';' before identifier 'typex'
c:\Boost\include\boost\archive\detail\oserializer.hpp(131) : error C2065: 'typex' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Drew Benton\My Documents\Visual Studio Projects\ProjectC\Debug\BuildLog.htm"
ProjectC - 3 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
#include <string>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <boost/serialization/utility.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/split_member.hpp>
class Engine
{
private:
int windowWidth;
int windowHeight;
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 save(Archive & ar, const unsigned int version)
{
ar & windowWidth;
ar & windowHeight;
}
template<class Archive>
void load(Archive & ar, const unsigned int version)
{
ar & windowWidth;
ar & windowHeight;
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
public:
Engine()
{
}
~Engine()
{
}
//friend
};
BOOST_CLASS_VERSION(Engine, 1)
int main(int argc, char* argv[])
{
const Engine myEngine;
// create and open a character archive for output
std::ofstream ofs("filename.txt");
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa << myEngine;
// Close the file
ofs.close();
return 0;
}