I have the following class:
#pragma once
#include <string>
#include <fstream>
#include <iostream>
#include <cereal\types\string.hpp>
using namespace std;
class Decryptor {
public:
Decryptor(string clear_set, string code_set);
Decryptor();
template<class Archive>
void serialize(Archive & ar);
private:
string clear_set = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string code_set = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
};
with the member function
template<class Archive>
void Decryptor::serialize(Archive & ar){
ar(clear_set, code_set);
}
and want to serialize/save an instance of it.
For that, in the main function I have
{
Decryptor user_dec;
ofstream savefile("mono.sav");
cereal::JSONOutputArchive archive(savefile);
archive(user_dec);
}
When compiling (in Visual Studio) I get the error
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Decryptor::serialize(class cereal::JSONOutputArchive &)" (??$serialize@VJSONOutputArchive@cereal@@@Decryptor@@QAEXAAVJSONOutputArchive@cereal@@@Z) referenced in function "public: static void __cdecl cereal::access::member_serialize(class cereal::JSONOutputArchive &,class Decryptor &)" (??$member_serialize@VJSONOutputArchive@cereal@@VDecryptor@@@access@cereal@@SAXAAVJSONOutputArchive@1@AAVDecryptor@@@Z)
I included the Cereal library with the NuGet Package Manager.
As I am fairly new to programming and just learning about templates and more advanced libraries, I don't really know how to deal with this.
Aucun commentaire:
Enregistrer un commentaire