From c933ca2ced2fe764560f43c66050a2b9510f57fa Mon Sep 17 00:00:00 2001 From: Thomas Sedlmayer Date: Fri, 4 Nov 2022 15:25:16 +0100 Subject: [PATCH 1/2] Add protobuf build instructions Signed-off-by: Thomas Sedlmayer --- doc/setup/build_install_example.adoc | 55 ++++++++++++++++------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/doc/setup/build_install_example.adoc b/doc/setup/build_install_example.adoc index a5c3d83..67f4326 100644 --- a/doc/setup/build_install_example.adoc +++ b/doc/setup/build_install_example.adoc @@ -19,7 +19,30 @@ Demonstrates a simple C network proxy that can send and receive OSI data via TCP **Prerequisites** * You have installed _cmake_ version 3.10.2 or higher. -* You have installed _protobuf_ version 3.0.0 or higher. +* You have installed _protobuf_ version 3.0.0 or higher (or follow the instructions in the next section to build protobuf by using vcpkg). + +**Profobuf Installation** + +Using vcpkg to properly build the required configurations of protobuf on Visual Studio (here VS 2017): + +. Install vcpkg as per the documentation, e.g. clone via git the bootstrap as needed +. English Language pack needs to be installed for VS 2017 for vcpkg to work +. Create a new triplet file for the required combination of static library linking with dynamic runtime (usually needed for dynamic linking to still work). Create a file named x64-windows-static-md-v141.cmake in the triplets directory with the following content: ++ +---- +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_PLATFORM_TOOLSET "v141") +---- ++ +*Note*: only need the v141 suffix and setting of VCPKG_PLATFORM_TOOLSET to ensure VS 2017 is selected if you have newer VS installed. + +. Now the protobuf libraries can be built automatically using: ++ +---- +vcpkg.exe install protobuf:x64-windows-static-md-v141 +---- **Steps** @@ -41,32 +64,16 @@ cd osi-sensor-model-packaging git submodule update --init ---- + -. Switch to the `examples/` directory. +. If you followed the protobuf installation instructions above you can use the built protobuf libraries to automatically build the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line: + ---- cd examples ----- -+ -. Create a new directory called `build/`. -+ ----- -mkdir -p build ----- -+ -. Switch to the `build/` directory. -+ ----- +mkdir build cd build +cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-v141 -DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake -G 'Visual Studio 15 2017 Win64' +cmake –build . ---- + -. Run _cmake_ in the parent directory. -+ ----- -cmake .. ----- -+ -. Run _cmake_ build. -+ ----- -cmake --build . ----- + +The CMAKE_TOOLCHAIN_FILE must point to your vcpkg directory, which in this example was parallel to the osi-sensor-model-packaging directory. +This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box). \ No newline at end of file From 13b155e5f278c1711116503b034d7e4f341ddf9f Mon Sep 17 00:00:00 2001 From: Thomas Sedlmayer Date: Fri, 4 Nov 2022 15:58:18 +0100 Subject: [PATCH 2/2] Add minor changes to protobuf build instructions Signed-off-by: Thomas Sedlmayer --- doc/setup/build_install_example.adoc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/setup/build_install_example.adoc b/doc/setup/build_install_example.adoc index 67f4326..53c7d13 100644 --- a/doc/setup/build_install_example.adoc +++ b/doc/setup/build_install_example.adoc @@ -19,9 +19,9 @@ Demonstrates a simple C network proxy that can send and receive OSI data via TCP **Prerequisites** * You have installed _cmake_ version 3.10.2 or higher. -* You have installed _protobuf_ version 3.0.0 or higher (or follow the instructions in the next section to build protobuf by using vcpkg). +* You have installed _protobuf_ version 3.0.0 or higher (or follow the instructions in the next section to build protobuf by using vcpkg on Windows). -**Profobuf Installation** +**Profobuf Installation (Windows)** Using vcpkg to properly build the required configurations of protobuf on Visual Studio (here VS 2017): @@ -64,16 +64,28 @@ cd osi-sensor-model-packaging git submodule update --init ---- + -. If you followed the protobuf installation instructions above you can use the built protobuf libraries to automatically build the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line: +. Run cmake and build +.. If you followed the protobuf installation instructions for Windows above you can use the built protobuf libraries to automatically build the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line: + ---- cd examples mkdir build cd build cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-v141 -DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake -G 'Visual Studio 15 2017 Win64' -cmake –build . +cmake –-build . ---- + The CMAKE_TOOLCHAIN_FILE must point to your vcpkg directory, which in this example was parallel to the osi-sensor-model-packaging directory. -This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box). \ No newline at end of file +This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box). + +.. If you did not install and build protobuf as explained above, use: ++ +---- +cd examples +mkdir build +cd build +cmake .. +cmake --build . +---- ++ \ No newline at end of file