Now that we know exactly what kind of OS, tools and libs we need need to build n3rv, let’s get to the real thing. Assuming that all the previously listed requirements are met, building n3rv is quite straightforward.
First we clone the n3rv repository on github:
git clone https://github.com/n3rvcpp/n3rv
Then we construct the MakeFile:
cd n3rv
cmake .
And to finish we build & install the library:
make && sudo make install
Assuming that you correctly installed the protobuf lib on your system and that you want n3rv to use it as main serialization method, here is what to do:
First, run cmake with -DWITH_PROTOBUF=yes
cd n3rv
cmake -DWITH_PROTOBUF=yes .
Next, you will need to compile the n3rvproto.proto file located in src/protocol/protobuf:
pushd .
cd src/protocol/protobuf
protoc n3rvproto.proto --cpp_out=.
poopd
Finally, build & install as usual:
make && sudo make install
As soon as you’ve succesfully built and installed the n3rv library, you can build all the examples that are located in n3rv/examples:
cd examples
cmake . && make
In order to check that the library was correctly compiled for your system, you can also build and run the unit tests:
cd tests
cmake . && make && ./tests
If you encounter troubles building the n3rv library, i suggest that you have a look at the following section:
As said in the requirements, n3rv requires the cppzmq header. Some distributions provide this heaver along with the libzmq-devel package but some don’t. If you don’t have this header on your system, you can add it by running the following command:
sudo wget -qO/usr/include/zmq.hpp https://raw.githubusercontent.com/zeromq/cppzmq/v<ZMQ_VERSION>/zmq.hpp
On some systems, the g++ std flag present in the Makefile can do some mess. If you have this error, here is what you can do:
This error may appear because your version of libevent is too old, you must use at least libevent v2.1. Either update your package if possible, or build libevent from sources.