Install

This chapter will explain how to install motorcortex-cpp.

Prerequisites

Two prerequisites need to be installed for motorcortex-cpp:

Prerequisite Installation Guide


The required version for MbedTLS is v3.6.3.1.


Installation

Follow these steps to download and install MbedTLS v3.6.3.1 from the official GitHub release:

  1. Download the release archive:

    wget https://github.com/Mbed-TLS/mbedtls/releases/download/v3.6.3.1/mbedtls-3.6.3.1.tar.bz2
    
  2. Extract the archive:

    tar -xjf mbedtls-3.6.3.1.tar.bz2
    cd mbedtls-3.6.3.1
    
  3. Build and install:

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

    ``

This will install the MbedTLS libraries and headers to your system (usually /usr/local). Running sudo ldconfig updates the shared library cache, which is required for the system to find the newly installed libraries.

For more details, see the official release page.

Uninstallation

MbedTLS does not provide a make uninstall target. To uninstall MbedTLS, you need to manually remove the installed files. By default, these are located in /usr/local.

  1. Remove installed libraries and headers:

    sudo rm -f /usr/local/lib/libmbed* /usr/local/lib/cmake/MbedTLS*
    sudo rm -rf /usr/local/include/mbedtls
    sudo ldconfig
    

    ``

    Note: If you installed MbedTLS to a custom prefix, adjust the paths accordingly.

  2. (Optional) Remove the source and build directories:

    cd ../..
    rm -rf mbedtls-3.6.3.1 mbedtls-3.6.3.1.tar.bz2
    

    ``

If you no longer need the source and build directories, you can remove them:

cd ../..
rm -rf mbedtls-3.6.3.1 mbedtls-3.6.3.1.tar.bz2

Use WSL2 on Windows and install everything as described in the Linux installation guide for the best compatibility and developer experience.


The required version for NNG is v1.10.0.


Installation

Follow these steps to download and install NNG from the official GitHub release:

  1. Download the release archive:

    wget https://github.com/nanomsg/nng/archive/refs/tags/v1.10.0.tar.gz
    

    ``

  2. Extract the archive:

    tar -xzf v1.10.0.tar.gz
    cd nng-1.10.0
    

    ``

  3. Build and install:

    mkdir build
    cd build
    cmake .. -DBUILD_SHARED_LIBS=1 -DNNG_ENABLE_TLS=1
    make
    sudo make install
    sudo ldconfig
    

    ``

This will install the NNG libraries and headers to your system (usually /usr/local). Running sudo ldconfig updates the shared library cache, which is required for the system to find the newly installed libraries.

For more details, see the official NNG release page.

Uninstallation

NNG does not provide a make uninstall target. To uninstall NNG, you need to manually remove the installed files. By default, these are located in /usr/local.

  1. Remove installed libraries and headers:

    sudo rm -f /usr/local/lib/libnng.*
    sudo rm -rf /usr/local/include/nng
    sudo ldconfig
    

    ``

    Note: If you installed NNG to a custom prefix, adjust the paths accordingly.

  2. (Optional) Remove the source and build directories:

    cd ../..
    rm -rf nng-1.10.0 v1.10.0.tar.gz
    

    ``


Use WSL2 on Windows and install everything as described in the Linux installation guide for the best compatibility and developer experience.

Installation

Motorcortex-cpp can be installed:


To install the motorcortex-cpp library on Linux, follow these steps:

  1. Install the required build tools if you haven’t already:

    sudo apt-get update
    sudo apt-get install build-essential cmake git
    
  2. Clone the motorcortex-cpp repository:

    git clone git@git.vectioneer.com:pub/motorcortex-cpp.git
    cd motorcortex-cpp
    
  3. Create a build directory and navigate into it:

    mkdir build
    cd build
    
  4. Run CMake to configure the build system:

    cmake ..
    
  5. Compile the library and install it:

    make
    sudo make install
    sudo ldconfig 
    

Uninstall

To uninstall the mcx-cpp library:

  1. Check where the files were installed (usually /usr/local/lib, /usr/local/include, etc.).

  2. Remove the installed files, for example:

    sudo rm -rf /usr/local/lib/libmcx*
    sudo rm -rf /usr/local/include/mcx*
    # Remove or update any other files installed by the library as needed
    sudo ldconfig
    

If you want to add an uninstall target in the future, you can use CMake scripts or tools like CPack.


To install Motorcortex-cpp on Windows, it is highly recommended to use WSL2 (Windows Subsystem for Linux) and follow the Linux installation guide for the best compatibility and developer experience.

WSL2 allows you to run a Linux environment directly on Windows, providing a more consistent development environment for building and using motorcortex-cpp. It can be easily setup on Windows 10 and Windows 11. Instruction can be found on the official Microsoft documentation: Install WSL.

Setup networking on WSL2

One important step when using WSL2 is to configure the networking correctly to allow communication between your Windows host and the WSL2 environment otherwise you cannot connect to the motorcortex application if it is connected via Ethernet or WiFi on the Windows host. By default, WSL2 uses a virtualized network interface which may not be directly reachable from the Windows host. To enable communication, you can set up a static route on your Windows host to route traffic to the WSL2 network. You can do this by running the following command in an elevated Command Prompt or PowerShell on Windows:

sudo ip route replace 192.168.2.0/24 via $(ip route | grep default | awk '{print $3}')

What this command does:

  • sudo ip route replace 192.168.2.0/24 via ... sets or updates a route on your WSL2 system so that traffic to the 192.168.2.0/24 network (replace this with your actual network if different) is sent via your default gateway.
  • $(ip route | grep default | awk '{print $3}') automatically finds the default gateway IP address used by WSL2.

When to change something:

  • If your Windows host or your local network uses a different subnet (not 192.168.2.0/24), replace 192.168.2.0/24 with the correct subnet for your setup. To find the correct subnet, you can check the IP address of your Windows host using ipconfig in Command Prompt and adjust accordingly.

Setting up VS Code for WSL2

To develop with VSCode in WSL2, you can run code . from within your WSL2 terminal. This will open VSCode connected to your WSL2 environment, allowing you to edit and build your motorcortex-cpp projects seamlessly. For running and debugging applications, you can find information in the official documentation: Developing in WSL.