How to build CppRestSDK using Vcpkg in Visual Studio 2019 (X64 windows & X86 windows)

 C++ REST SDK



The C++ REST SDK is developed by Microsoft.

It's a  modern asynchronous C++ API design  for cloud-based client-server communication in native code. 

By using this project  C++ developers can connect to and interact with services.

C++ REST SDK can be installed on Windows by using VCPKG


Download C++ Rest SDK GitHub Repo - Microsoft Original Repository


Install packages with VCPKG 

Install Visual Studio with C++ 

Install Windows SDK 




git clone https://github.com/microsoft/cpprestsdk.git

Go inside VCPKG folder


.\vcpkg\bootstrap-vcpkg.bat 

To use vcpkg with Visual Studio, Run the command below.

.\vcpkg\vcpkg integrate install 


Run Following command to install the libraries list zlib ,openssl ,boost-system, boost-date-time ,boost-regex, boost-interprocess, websocketpp, brotli

X64 

vcpkg install --triplet x64-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli


X86

vcpkg install --triplet x86-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli


Open cppretsdk in Visual Studio 2019 IDE

Right click on the file explorer window 


Open in Visual Studio 2019


Open & Edit CMakeSettings.json file - Add X64 and X86 settings


{
  "configurations": [
    {
      "buildCommandArgs": "",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "cmakeCommandArgs": "",
      "cmakeToolchain": "${projectDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
      "configurationType": "Debug",
      "ctestCommandArgs": "",
      "generator": "Visual Studio 16 2019 Win64",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "intelliSenseMode": "windows-msvc-x64",
      "name": "x64-Debug (default)",
      "variables": [
        {
          "name": "VCPKG_TARGET_TRIPLET",
          "value": "x64-windows",
          "type": "STRING"
        },
        {
          "name": "Boost_USE_STATIC_LIBS",
          "value": "False",
          "type": "BOOL"
        },
        {
          "name": "CPPREST_FILEIO_IMPL",
          "value": "win32",
          "type": "STRING"
        },
        {
          "name": "_VCPKG_INSTALLED_DIR",
          "value": "${projectDir}/vcpkg/installed",
          "type": "PATH"
        },
        {
          "name": "LIB_EAY_RELEASE",
          "value": "${projectDir}/vcpkg/installed/x64-windows/debug/lib/libcrypto.lib",
          "type": "FILEPATH"
        },
        {
          "name": "OPENSSL_APPLINK_SOURCE",
          "value": "${projectDir}/vcpkg/installed/x64-windows/include/openssl/applink.c",
          "type": "FILEPATH"
        },
        {
          "name": "SSL_EAY_RELEASE",
          "value": "${projectDir}/vcpkg/installed/x64-windows/lib/libssl.lib",
          "type": "FILEPATH"
        },
        {
          "name": "WEBSOCKETPP_DIR",
          "value": "${projectDir}/vcpkg/installed/x64-windows/share/websocketpp",
          "type": "PATH"
        }
      ]
    },
    {
      "buildCommandArgs": "",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "cmakeCommandArgs": "",
      "cmakeToolchain": "${projectDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
      "configurationType": "Debug",
      "ctestCommandArgs": "",
      "generator": "Visual Studio 16 2019",
      "inheritEnvironments": [ "msvc_x86" ],
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "intelliSenseMode": "windows-msvc-x86",
      "name": "x86-Debug",
      "variables": [
        {
          "name": "VCPKG_TARGET_TRIPLET",
          "value": "x86-windows",
          "type": "STRING"
        },
        {
          "name": "Boost_USE_STATIC_LIBS",
          "value": "False",
          "type": "BOOL"
        },
        {
          "name": "CPPREST_FILEIO_IMPL",
          "value": "win32",
          "type": "STRING"
        },
        {
          "name": "_VCPKG_INSTALLED_DIR",
          "value": "${projectDir}/vcpkg/installed",
          "type": "PATH"
        },
        {
          "name": "LIB_EAY_RELEASE",
          "value": "${projectDir}/vcpkg/installed/x86-windows/debug/lib/libcrypto.lib",
          "type": "FILEPATH"
        },
        {
          "name": "OPENSSL_APPLINK_SOURCE",
          "value": "${projectDir}/vcpkg/installed/x86-windows/include/openssl/applink.c",
          "type": "FILEPATH"
        },
        {
          "name": "SSL_EAY_RELEASE",
          "value": "${projectDir}/vcpkg/installed/x86-windows/lib/libssl.lib",
          "type": "FILEPATH"
        },
        {
          "name": "WEBSOCKETPP_DIR",
          "value": "${projectDir}/vcpkg/installed/x86-windows/share/websocketpp",
          "type": "PATH"
        }
      ]
    }
  ]
}

Build cpprestsdk  - X64

Select X64-Debug (default) for build configuration

Select & Right Click on CMakeLists.txt 



Select & Click Build

Before Building it for X64 following command should have been executed & packages should have been installed properly


vcpkg install --triplet x64-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli

You can find the built libraries in the below folder

cpprestsdk\out\build\x64-Debug (default)\Release\Binaries\Debug folder


Build cpprestsdk  - X86

Select X86-Debug  for build configuration

Select & Right Click on CMakeLists.txt 

Select & Click Build

Before Building it for X86 following command should have been executed & packages should have been installed properly


vcpkg install --triplet x86-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli

You can find the built libraries in the below folder

cpprestsdk\out\build\x86-Debug\Release\Binaries\Debug



Source Code Download 














Comments

Popular posts from this blog

How to Call Webservice through C++ Dynamic Link Library (DLL) in Visual Studio 2019 Using C++ Rest SDK

Implementing ResNet with Base Line Accuracy