Skip to content
Marc edited this page Aug 1, 2018 · 3 revisions

To use the library, you first have to download this repository and add the header files inside Cereal/Cereal to your project. You should have the following items:

  • Cereal.h
  • src/Array.h
  • src/Buffer.h
  • src/Database.h
  • src/Field.h
  • src/Header.h
  • src/Internal.h
  • src/Object.h
  • src/Reader.h
  • src/Writer.h

Then, you need to link those file into your project. The next sections will describe the specific setup for G++/Clang and for Microsoft Visual Studio.

G++/Clang

For G++/Clang, you only need to add the header files into the include search path of your program. This is done using the -I parameter as follows: -Irelative/path/to/Cereal. Also remember to add the -std=c++11 parameter to the command, because Cereal uses C++11 and if this parameter is not present, the compilation will fail.

An example compilation command could look as follows:

marcizhu@linux:~/project $ g++ main.cpp -Iinclude/ -Wall -O2 -std=c++11 -o output_file

Finally, you'll only need to include Cereal.h and start using it.

Microsoft Visual Studio

For Visual Studio, open the project settings and go to the Project paths page. There, inside Include paths, and the path to Cereal.

Once all those files are linked to your project, now you only have to include Cereal.h and start using it! All the clases are inside the namespace Cereal, so you might consider adding a using namespace Cereal; on the top of your code.

Pretty simple, right?