Skip to content

Instantly share code, notes, and snippets.

@randvoorhies
Created December 19, 2013 01:50
Show Gist options
  • Save randvoorhies/8033009 to your computer and use it in GitHub Desktop.
Save randvoorhies/8033009 to your computer and use it in GitHub Desktop.
rand@Randolphs-MacBook-Pro:~/workspace/sandbox$ make
g++-4.9 -std=c++11 main2.cpp obj1.cpp obj2.cpp -I../cereal/include
duplicate symbol cereal::detail::Versions::mapping in:
/var/folders/z8/8m9443jx2rsdv_c908pn00m00000gn/T//cceemLWz.o
/var/folders/z8/8m9443jx2rsdv_c908pn00m00000gn/T//cckqajum.o
duplicate symbol cereal::detail::Versions::mapping in:
/var/folders/z8/8m9443jx2rsdv_c908pn00m00000gn/T//cceemLWz.o
/var/folders/z8/8m9443jx2rsdv_c908pn00m00000gn/T//ccgHDFrZ.o
ld: 2 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
#include "obj1.hpp"
#include "obj2.hpp"
#include <cereal/archives/xml.hpp>
#include <fstream>
int main()
{
obj1 o1;
obj2 o2;
std::ofstream ostream("archive.xml");
cereal::XMLOutputArchive oarchive(ostream);
oarchive( o1, o2 );
}
all:
g++-4.9 -std=c++11 main2.cpp obj1.cpp obj2.cpp -I../cereal/include
#include "obj1.hpp"
obj1::obj1()
{
x = 99;
}
#pragma once
#include <cereal/access.hpp>
#include <cereal/cereal.hpp>
class obj1
{
public:
obj1();
protected:
friend class cereal::access;
template <class Archive>
void serialize(Archive & ar)
{
ar( cereal::make_nvp<Archive>( "x_value", x ) );
}
int x;
};
#include "obj2.hpp"
obj2::obj2()
{
y = 100;
}
#pragma once
#include <cereal/access.hpp>
#include <cereal/cereal.hpp>
class obj2
{
public:
obj2();
protected:
friend class cereal::access;
template <class Archive>
void serialize(Archive & ar)
{
ar( cereal::make_nvp<Archive>( "y_value", y ) );
}
int y;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment