Setup Cross Compilation
3 minute read
Set-up Cross Compilation (In Clion)
For cross compilation you use … (with remote device libraries).
Install Motorcortex toolchain on your system
For Cross compilation you will need a
Motorcortex SDK you can download the SDK (Software Developement Kit) from the motorcortex.io store by pressing the download button below.
Extract the archive and place the
.shfile in a folder of your preference.
In the terminal browse to the folder and run the
.shfile from the terminal, for example:
- You will be asked to enter the target directory where to install the SDK to. It is a good idea to keep the SDK in the home folder, where administrative rights are not required for example:
Mounting Sysroot on your system
The first step to Cross Compilation is to mount a
Sysroot directory to your system that is used for cross-compilation. A `Sysroot is a directory which is considered to be the root directory for the purpose of locating headers and libraries of your application.
- Generate a new key pair with the following command.
ssh-keygen -t rsa
NoteThe prompt will ask you to set a password. This is not needed but optional if desired.
ssh-copy-idto provide a temporary access without a password to the remote Motorcortex host. If you are asked to fill in a password use
- Create a folder to mount the remote Motorcortex file system on with the following command.
- Ensure that
sshfsis installed with the following command:
sudo apt-get install sshfs
- Mount the Motorcortex file system with the following command:
sshfs email@example.com:/ ~/mcx-sysroot/
NoteYou will need to execute this last command every time after you logout or reboot your development system.
Configure toolchain in clion.
Configure the compiler paths to use the Motorcortex cross-compilation toolchain.
File → Settings → Build Execution Deployment → Toolchains.
Create a new
System Toolchainwith the name
Fill in Make, C Compiler and C++ Compiler paths to point the Motorcortex SDK as shown below.
- C Compiler:
- C++ Compiler
Applyto save the changes.
Setup toolchain plugin
Configure sysroot path to use the headers and libraries from the remote host.
File → Settings → Build, Execution, Deployment → **Motorcortex SDKand fill in the
Sysroot pathpath the mounted folder (mcx-sysroot).
Add deployment connection to remote host (IS THIS STILL NEEDED IN THE NEW VERSION ALEXEY!!??)
Add the connection to the remote Motorcortex host.
Open Tools → Deployment → Configuration, add a new
select or add ssh configuration.
Test Connection button to make sure that the filled data is correct.
Autodetect button to set the root path. Uncheck the
Visible only for this project checkbox make this host visible in all the projects.
Cross-compiling Motorcortex applications.
select mcx dingie
save password checkbox
deployment profile to mxc-host
- In CLion open the project configuration menu.
- Click on
Motorcortex Remote Application. In the deployment profile field select Motorcortex remote host.
copy config folder
In the Run/Debug configuration select the just created cross-compiled application with
hammerbutton to cross-compile,
playto copy and run on the remote Motorcortex host and the
bugbutton to start a remote debug session.
Note if CMake CrossDebug/CrossRelease don’t work remove the “Motorcortex Remote Application” from Run/Debug Configurations and try again