Skip to content

v2_0_cpp_tutorial

Takatoshi Kondo edited this page Apr 9, 2018 · 12 revisions

Tutorial

How to compile

msgpack-c is a header only library. You can just add msgpack-c/include to the compiler include path.

g++ -Ipath_to_msgpack-c/include your_source.cpp

Checking the version

In order to use msgpack-c, you need to include msgpack.hpp in your source code. It is a convenience header file that contains all msgpack-c functionalities.

After include the header file, I recommend checking the version of msgpack-c.

Here is an example:

#include <iostream>

#include <msgpack.hpp>

int main() {
    std::cout << MSGPACK_VERSION << std::endl;
}

https://wandbox.org/permlink/9g8uhDsVHAW1rpwV

Because some environment often has installed older-version of the msgpack-c in /usr/include. It is very confusing. So I recommend the version of msgpack-c that actually you include.