
I'm trying to both serialize and deserialize the data in a graph format. The definition of my graph is the following one. #include <boost/graph/adjacency_list.hpp> #include <boost/graph/directed_graph.hpp> #include <boost/graph/adj_list_serialize.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/binary_object.hpp> class VFull { public: VFull(); unsigned int id, hash, year; std::string ip, organization; VFull(unsigned int id, unsigned int hash, unsigned int year, std::string ip, std::string organization); template<class Archive> void serialize(Archive & ar, const unsigned int version); }; class EFull { public: EFull(); template<class Archive> void serialize(Archive & ar, const unsigned int version); }; class GFull { public: template<class Archive> void serialize(Archive & ar, const unsigned int version); }; //Defining the graph data structure. Using the vecS specification typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,VFull,EFull,GFull> graph_t; typedef boost::graph_traits<graph_t>::vertex_descriptor result_vertex_descriptor; typedef boost::graph_traits<graph_t>::edge_descriptor result_edge_descriptor; It seems to me that I have no problems in the serialization process, while I have some issues in the deserialization part. In fact, I have no linking errors until this piece of code is added to my source: #include <iomanip> #include <iostream> #include <fstream> { std::ifstream file(path,std::ios_base::binary); boost::archive::binary_iarchive store{file}; store >> graph; // Deserialization part that triggers the error } I tried to read some questions here and to read the Boost manual, but they didn't solve my problem. In particular, I have this error: Undefined symbols for architecture x86_64: "void EFull::serialize<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int)", referenced from: void boost::serialization::access::serialize<boost::archive::binary_iarchive, EFull>(boost::archive::binary_iarchive&, EFull&, unsigned int) in boostOthers.cpp.o "void GFull::serialize<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int)", referenced from: void boost::serialization::access::serialize<boost::archive::binary_iarchive, GFull>(boost::archive::binary_iarchive&, GFull&, unsigned int) in boostOthers.cpp.o "void VFull::serialize<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int)", referenced from: void boost::serialization::access::serialize<boost::archive::binary_iarchive, VFull>(boost::archive::binary_iarchive&, VFull&, unsigned int) in boostOthers.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) By the way, I'm serializing and deserializing strings and unsigned ints, "native data types" that seems to be supported by boost: //VERTICES VFull::VFull() { } VFull::VFull(unsigned int i, unsigned int h, unsigned int y, std::string p, std::string o) : id{i}, hash{h}, year{y}, ip{p}, organization{o} { } template<class Archive> void VFull::serialize(Archive &ar, const unsigned int version) { ar & 'i'; ar & id; ar & 'h'; ar & hash; ar & '1'; ar & ip; ar & '2'; ar & organization; ar & '3'; ar & year; ar & '/'; } /////// //EDGES EFull::EFull() { } template<class Archive> void EFull::serialize(Archive &ar, const unsigned int version) { char waste = 'e'; ar & waste; } /////// //GRAPH SIGNATURE template<class Archive> void GFull::serialize(Archive &ar, const unsigned int version) { std::string waste = "GBLS"; ar & waste; } /////// Yes, I am linking my source code to both BGL and Boost's serialization. This is acheived through this part of CMake script: find_package( Boost REQUIRED COMPONENTS graph serialization ) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED OFF) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ..some other stuff..) TARGET_LINK_LIBRARIES(mycode ${Boost_LIBRARIES})