Install

This chapter will explain how to install motorcortex-cpp.

Prerequisites

mbed TLS https://tls.mbed.org/ (optional, only required for encrypted communication)

Download the latest stable version, or clone from the mbedtls git repository

When cloning from the mbedtls git repository make sure to switch to the master branch after cloning (the default branch is development)

nng - nanomsg-next-gen https://github.com/nanomsg/nng

Installation

These steps here are the minimum steps to get a default Debug build. Using CMake you can do many other things, including setting additional variables, setting up for static builds, or generation project or solution files for different development environments. Please check the CMake website for all the various options that CMake supports.

Linux

mbed TLS

mkdir build
cd build
cmake .. -DUSE_SHARED_MBEDTLS_LIBRARY=1
make
sudo make install

nng - nanomsg-next-gen

mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=1 #optional: -DNNG_ENABLE_TLS=1
make
sudo make install

motorcortex-cpp

mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig 

MacOS

Windows

The steps here are the minimum steps to get a default Debug build working from the command line and should be seen as a Quickstart guide.

Similar settings will be required when using an IDE (e.g VS Code or VS Codium)

Microsoft C++ Build Tools (Visual Studio)

Extra Prerequisites

Microsoft C++ Build Tools https://visualstudio.microsoft.com/visual-cpp-build-tools/

Download the latest version of the build tools.

Installation

Create a workspace directory (e.g c:\workspace), and extract mbedtls, nng, and motorcortex-cpp to this directory.

Create an installation directory for convenience (e.g c:\mcx-install).

Launch a development command prompt by using the batch file included with build tools (for 2019 version):

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\LaunchDevCmd.bat

NOTE: Library versions are subject to change (mbedtls-2.16.6, nng-1.3.0)

Run the following commands (all in the same development command prompt):

set ws=c:\workspace
set id=c:\mcx-install
set PATH=%mw%\bin;%mw%\lib;%PATH%

mbed TLS

cd %ws%\mbedtls-2.16.6
md build
cd build
cmake .. -DENABLE_TESTING=Off -DUSE_SHARED_MBEDTLS_LIBRARY=1 -DCMAKE_INSTALL_PREFIX=%id%
msbuild INSTALL.vcxproj &REM Needs to run twice as the first time gives an
msbuild INSTALL.vcxproj &REM error due to a problem in the build order

nng - nanomsg-next-gen

cd %ws%\nng-1.3.0
md build
cd build
cmake .. -DBUILD_SHARED_LIBS=1 -DNNG_ENABLE_TLS=1 -DCMAKE_INSTALL_PREFIX=%id%
msbuild INSTALL.vcxproj

motorcortex-cpp

cd %ws%\motorcortex-cpp
md build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=%id%\include -DCMAKE_INSTALL_PREFIX=%id%
msbuild INSTALL.vcxproj

MinGW-W64

Extra Prerequisites

MinGW-W64 https://sourceforge.net/projects/mingw-w64

Download the x86_64-posix-seh version (tested with MinGW-W64 GCC-8.1.0) and extract to c:\ which will make the mingw64 root c:\mingw64

CMake

Download the lastest CMake installer, and install with one of the “Add CMake to the system Path …” options.

Installation

Create a workspace directory (e.g c:\workspace), and extract mbedtls, nng, and motorcortex-cpp to this directory.

NOTE: Library versions are subject to change (mbedtls-2.16.6, nng-1.3.0)

Open a command prompt and run the following commands (in the same command prompt):

set mw=c:\mingw64
set ws=c:\workspace
set PATH=%mw%\bin;%mw%\lib;%PATH%

mbed TLS

cd %ws%\mbedtls-2.16.6
md build
cd build
cmake .. -DENABLE_TESTING=Off -DUSE_SHARED_MBEDTLS_LIBRARY=1 -DCMAKE_INSTALL_PREFIX=%mw% -G "MinGW Makefiles"
mingw32-make install

nng - nanomsg-next-gen

cd %ws%\nng-1.3.0
md build
cd build
cmake .. -DBUILD_SHARED_LIBS=1 -DNNG_ENABLE_TLS=1 -DCMAKE_INSTALL_PREFIX=%mw% -G "MinGW Makefiles"
mingw32-make install

motorcortex-cpp

cd %ws%\motorcortex-cpp
md build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=%mw%\include -DCMAKE_INSTALL_PREFIX=%mw% -G "MinGW Makefiles"
mingw32-make install