Custom Protobuf Build
Build and Install Protobuf
As Protobuf can be installed easily as binary package in different versions (see Installing the Binary Packages) via appropiate package managing systems, there is usually no need to build protobuf from source. However, if a custom build is necessary, this section gives instructions, how to compile version 3.17.3. and hook it into the openPASS build. This currently applies to the openPASS build, as static and shared libraries of Protobuf are required. Adjust this guide to your needs.
Download release 3.17.3 from https://github.com/protocolbuffers/protobuf/releases
Extract
for Windows to
C:\OpenPASS\thirdParty\sources\protobuf-cpp-3.17.3
for Linux to
~/OpenPASS/thirdParty/sources/protobuf-cpp-3.17.3
Navigate to the extracted folder
Start
MinGW 64-bit
shellcd /C/OpenPASS/thirdParty/sources/protobuf-cpp-3.17.3
Start
Bash
shellcd ~/OpenPASS/thirdParty/sources/protobuf-cpp-3.17.3
Create build directory
cd cmake mkdir build cd build
Run CMake
cmake -G "MSYS Makefiles" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=C:/OpenPASS/thirdParty/protobuf \ -Dprotobuf_BUILD_SHARED_LIBS=OFF \ -Dprotobuf_BUILD_TESTS=OFF \ ..
cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=~/OpenPASS/thirdParty/protobuf \ -Dprotobuf_BUILD_SHARED_LIBS=OFF \ -Dprotobuf_BUILD_TESTS=OFF \ ..
Note
Tests are disabled due to compiler warnings treated as errors (may vary with compiler version).
Compile
make -j3
Install
make install
Note
After completion, repeat the steps described above with the following changes applied to the CMake call:
Set
protobuf_BUILD_SHARED_LIBS
toON
Use
~/OpenPASS/thirdParty/protobuf-shared
asCMAKE_INSTALL_PREFIX
This will build and install the dynamic libraries of Protobuf.
Hook Protobuf into OSI
If you want to build and install OSI with a custom build of Protobuf, most of the steps can be followed as described in instruction Build and Install OSI. However, one step must be added.
For all required steps before the following command, see Build and Install OSI.
Additional
CMake
variables have to be set.cmake -G “MSYS Makefiles” \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=C:/OpenPASS/thirdParty/osi \ -DPROTOBUF_INCLUDE_DIR=C:/OpenPASS/thirdParty/protobuf-shared/include \ -DPROTOBUF_PROTOC_EXECUTABLE=C:/OpenPASS/thirdParty/protobuf-shared/bin/protoc.exe \ -DPROTOBUF_LIBRARY=C:/OpenPASS/thirdParty/protobuf-shared/lib/libprotobuf.dll.a \ ..
cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=~/OpenPASS/thirdParty/osi \ -DPROTOBUF_INCLUDE_DIR=~/OpenPASS/thirdParty/protobuf-shared/include \ -DPROTOBUF_PROTOC_EXECUTABLE=~/OpenPASS/thirdParty/protobuf-shared/bin/protoc \ -DPROTOBUF_LIBRARY=~/OpenPASS/thirdParty/protobuf-shared/lib/libprotobuf.so \ ..
For all required steps after this stage, see Build and Install OSI.