Environment Setup

The main tool for building, testing and deploying software is CMake. It is widely accepted and supported by many IDEs, which means that the user is free to choose from various development environments.

To make things more convenient, there are Motorcortex plugins for CLion ( https://www.jetbrains.com/clion ). CLion is an advanced IDE with many tools that make programming a Motorcortex application easier. This IDE is available across platforms and is capable of cross-compiling and deploying Motorcortex applications to the target controller with a click of a button. This guide will show you how to install CLion, Motorcortex plugins from the CLion Marketplace and get started with developing Motorcortex applications.


Installing Motorcortex Plugins

There are two CLion plugins that make developing Motorcortex applications easier: Motorcortex Templates and Motorcortex ToolChains.

Both can be installed in the plugin menu of Clion.

  1. In the Main Menu on the top left corner open: File → Settings, then find the Plugins menu.

  2. In the plugins menu search for Motorcortex.

  3. Install both Motorcortex Templates and Motorcortex ToolChains plugins

  4. Press restart IDE -> press Restart.

    image not found

Creating a New Motorcortex Project

Using the Motorcortex Templates plugin you can create a new Motorcortex project directly from CLion. This will setup a basic Motorcortex project structure for you with all necessary files. You an then easily develop, build and deploy your application from within CLion.

  1. In the Main Menu on the top left corner open: File → New Project.

  2. In the new project menu select C++ Motorcortex on the left side.

  3. Fill in the Location and select the options you want.

  4. Press Create.

    image not found

Setup-up Toolchains

In Clion you can setup different toolchains to build your Motorcortex applications. Using the Motorcortex ToolChains plugin you can easily setup the toolchains needed for cross-compiling and remote development.

Install Motorcortex SDK

  1. From the Motorcortex store download the latest Motorcortex SDK for your system, for example mcx-rtos-glibc-x86_64-mcx-image-dev-corei7-64-mcx-intel-toolchain-2025.03-0-g0e9d0e9.sh.

  2. Give the file execution permissions: (Replace the filename with the one you downloaded)

    chmod +x mcx-rtos-glibc-x86_64-mcx-image-dev-corei7-64-mcx-intel-toolchain-2025.03-0-g0e9d0e9.sh
    
  3. Run the installer: (Replace the filename with the one you downloaded)

    ./mcx-rtos-glibc-x86_64-mcx-image-dev-corei7-64-mcx-intel-toolchain-2025.03-0-g0e9d0e9.sh
    
  4. Follow the instructions on screen to complete the installation. Make sure to remember the installation path, you will need it in the next step.

Make sure to install the SDK that matches your Motorcortex controller version. You can check your controller version by running cat /etc/issue on the controller terminal.

System Toolchain

  1. In the Main Menu on the top left corner open: File → Settings, then find the Build, Execution, Deployment → Toolchains menu.
  2. Add a new toolchain by pressing the button and select system.
  3. Rename it to motorcortex. (This is case-sensitive)
  4. Add environment by pressing Add environment and selecting from file. In the Environment file path enter the path to the mcx-clion-environment.sh file in the Motorcortex SDK installation directory.
    image not found
  5. Change the build tool to make if it is not already selected. (Ninja is supported but it will give a warning in the CMake window which can be ignored)
  6. Press Apply to save the toolchain settings.
    image not found
  7. Remove the default toolchain or move it below the motorcortex toolchain to make sure the Motorcortex toolchain is used by default.

Remote Host

For this step, make sure you are connected to your Motorcortex controller via Ethernet. See Connecting to your Motorcortex Controller for more information.

  1. In the Main Menu open File → Settings under Build, Execution, Deployment you will find the Toolchains menu.

  2. Add a new toolchain by pressing the button and select Remote Host.

  3. In the Credentials: press the button to enter the SSH Configurations menu. Add a new configuration by pressing the button and fill in the following data:

    • Host: 192.168.2.100 or the IP address of your Motorcortex controller if you changed it.
    • Port: 22
    • User name: admin or your custom username if you changed it.
    • Password: vectioneer or your custom password if you changed it.
  4. Press the Test Connection button to make sure your connection is OK. If not, re-check your controller connection.

  5. If the connection is good you can press OK to close the SSH Configurations menu.

  6. Wait for Cmake and the C/C++ Compiler to be detected:

    • CMake: Remote host CMake
    • Build Tool: Default, Detected: make
    • C Compiler: Default, Detected: cc
    • C++ Compiler: Default, Detected: c++
    • Debugger:Remote Host GDB
  7. Press the Apply button to save the Toolchain settings.

image not found

Run/Debug Configurations

To easily build and run your Motorcortex application from within CLion you can setup Run/Debug configurations for both cross-compiling and remote development. With the Motorcortex ToolChains plugin this is also made easy.

  1. In the top bar select and select configuration edit....
    image not found
  2. Press the button to add a new configuration and select Motorcortex Remote Application.
  3. You can name the configuration as you like, for example mcx-example.
  4. In the Program arguments field add the following:
    -s -c /etc/motorcortex/config/config.json
    
  5. Make sure that the Deployment profile automatically selected Remote Host ($ID$) as the option, with $ID$ being the ID of your remote host toolchain.
  6. Press Apply to save the configuration.
image not found

When you pressed apply it should have automatically created two new folders in your project directory: cmake-build-crossdebug and cmake-build-crossrelease. In the Cmake window of Clion a warning might appear but this can be ignored:

CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_VERBOSE_MAKEFILE

Using the Toolchains

Compiling and Debugging/Running

  1. In the top right corner of CLion select the Run/Debug Configuration you created earlier, for example mcx-example.
  2. To build the application press the button.
  3. To run or debug the application press the or button.

Installing and Running your Application Remotely

  1. In control/MainControlLoop.cpp, change the current iterateOp function to the following code:

       bool MainControlLoop::iterateOp_(const container::TaskTime &systemTime, container::UserTime *userTime) {
          log_info("Test");
    
          return true;
       }
    
  2. In CLion set your Run/Debug Configuration to Remote Host.

  3. Press Install (Located under build in the top bar). This will install the application on the Motorcortex controller.

  4. After installation is complete, open a terminal, either in CLion or your system terminal.

  5. Run the following command to ssh into the the Motorcortex controller: (Update the Username and IP address if needed)

    ssh admin@192.168.2.100
    
  6. Once logged in, run the following command to restart the Motorcortex application:

    sudo motorcortex restart
    
  7. Run the following command to view the output logs:

    mcx-lastlog
    
  8. You should see the Test log message appearing every control loop iteration.

For more information on control application development, please refer to the Developing Control Applications section of the documentation.

Common issues

If you encounter issues while setting up or using the Motorcortex toolchains in CLion, here are some common problems and their solutions:

  • fatal error: mcx/core.h: No such file or directory: This error indicates that the Motorcortex SDK is not properly configured in the toolchain. Make sure you have the motorcortex toolchain as the top priority toolchain and that the environment file path is correctly set to the mcx-clion-environment.sh file in the Motorcortex SDK installation directory. Remove the Default toolchain if necessary or move it below the motorcortex toolchain. Remove the cmake-build directories and press Reload CMake Project in CLion.

  • Removing Cmake-build directories: If you encounter build issues, try removing the cmake-build-crossdebug and cmake-build-crossrelease directories in your project folder. This will force CLion to regenerate the build files and can resolve various build-related problems.


Set-up Remote Development:

After installing Visual Studio Code the first step is to install the Remote Development extension:

  • Remote Development, allows you to use a remote machine as full-feautured development environment.

Inside the primary side bar per default on the left side of your main menu, press Extensions(Crtl+Shift+X).

  1. Inside the EXTENSIONS tab use the search Extensions in Marketplace to find the following extension: Remote Development.

    image not found

  2. Press install, to install the Remote Development to your local machine.

Your local machine extensions are now installed!

  1. With Remote Development installed, inside the primary side bar an item REMOTE EXPLORER is added, press to open.

  2. Inside the REMOTE EXPLORER select SSH TARGETS press Add New.

  • Enter SSH Connection Command: ssh admin@192.168.2.100, press Enter to confirm.
    image not found
  • Select SSH configuration file to update: /home/username/.ssh/config (To update your config locally, use /etc/ssh/ssh_config to update remote.).
    image not found
  1. Right click on 192.168.2.100, press Connect to Host in Current Window.
    image not found
  • Enter password for $admin@192.168.2.100: vectioneer, press enter.
    image not found
  • In the bottom bar in green you see SSH:192.168.2.100, this means that the connection is established:
    image not found
  • The EXPLORER Window is now opend:
    image not found
  1. With the remote device connected you can install the C/C++ and Motorcortex Template extensions to your remote controller:
    image not found
  • Press: install in SSH:192.168.2.100.

Your controller has all extensions installed and is connected with Visual Studio Code!

Create and build a Motorcortex Project:

  1. Inside EXPLORER under NO FOLDER OPENED connect to remote, press OPEN FOLDER, select home/admin/ press OK.
    image not found
  • This opens in EXPLOROR Window -> ADMIN[SSH:192.168.2.100].
    image not found
  1. Inside ADMIN[SSH:192.168.2.100], Press New Folder... to create a new folder, Enter name: Test.

  2. Use keyboard shortcut ctrl+shift+p, search for: File: Open Folder..., enter: /home/admin/Test -> press OK.

    image not found

  • Enter password for $admin@192.168.2.100: vectioneer, press enter.
    image not found
  1. Inside this folder create a new Motorcortex Project, use keyboard shortcut ctrl+shift+p, search for Motorcortex Create Project.
    image not found
  • Name your Motorcortex project, for exampje: Test.
    image not found
  • Now your project is visual in the EXPLORER it should look like this:
    image not found
  1. This project inside TEST[SSH:192.168.2.100], uses CMake to build, for this you have to assign the following kit:
  • Use keyboard shortcut ctrl+shift+p, search for CMake: Select a Kit.
  • Select a Kit for Test: GCC 9.3.0 x86_64-mcx-linux.
    image not found
  • In the bottom bar in blue GCC 9.3.0 x86_64-mcx-linux, this will show you which kit is active:
    image not found
  1. Now you can try to build your program on the controller, go to top menu bar -> press Run -> press Run Without Debugging.
    image not found

Your Motorcortex program is now running on you controller!

Add Motorcortex Module to Motorcortex Project:

  1. Inside your Motorcortex Project, use keyboard shortcut ctrl+shift+p, search for Motorcortex Create Module.
  • Fill in the name of your file, example test:
    image not found
  • Fill in the name of your class, example testClass:
    image not found
  1. You have created your Motorcortex Module:
    image not found

Your Motorcortex Module is now added to your Motorcortex Project!