Using NI Linux Real-Time Cross Compile Toolchain with Visual Studio Code

Updated Feb 21, 2025

Environment

Software

  • Vehicle Communication Toolkit

Operating System

  • LabVIEW Real-Time (NI Linux Real-Time)

To implement custom checksum with VCOM, the Linux RT so file is needed. This article will introduce how to setup the compile toolchain to generate the so file for custom checksum.

Required Software

  • Visual Studio Code
  • GNU C&C Compilers for x64 Linux
  • MobaXterm
  • CMake
  • Ninja

Installing Visual Studio Code

  1. Navigate to the Visual Studio Code Installation Page.
  2. Download the IDE installer for Windows.
  3. Run the setup.exe.
  4. Follow the onscreen prompts to install.
  5. Once finished, launch Visual Studio Code.

Installing Extensions

  1. In Visual Studio Code, open the Extensions pane by clicking the extension's icon on the left of the IDE.

  1. Search and install the C/C++ Extension Pack.

Installing the C/C++ Cross Compile Toolchains

  1. Navigate to the GNU C & C++ Compile Tools x64 and download the Windows toolchains for x64. The toolchain is a compressed collection of the required files rather than an installer.
  2. Extract and copy the contents of the toolchain to C:\build\<toolchain version>\x64\. The resulting file structure should look as follows:

MobaXterm

MobaXterm will be used as a sFTP client to transfer files to and from a NI Linux Real-Time system as needed. Remote host : IP address of Linux RT. Specify username : user name of Linux RT.

CMake

CMake is a tool that generates the files needed for build tools such as Make or Ninja. NI recommends adding CMake to the system PATH during installation for ease of use:

Ninja

Ninja is a small build system and one of the tools CMake can generate build files for. Since installing Ninja is a bit more involved than simply running a Windows installer, follow the below steps to ensure it’s configured correctly.

  1. Download the Ninja binary files for Windows.
  2. Extract and copy Ninja.exe to a suitable location (e.g., C:\Program Files\Ninja\).

  1. The executable can be added to the system PATH for easier use. Press Start+R to open the Run window, then type in sysdm.cpl and hit OK. This will launch the System Properties window.
  2. In the System Properties window, navigate to the Advanced page and select Environment Variables… to open the Environment Variables window.
  3. In the System variables section of the Environment Variables window, navigate to and select Path then click Edit…
  4. In the Edit environment variable window, click New to add a new path.
  5. Enter the path to the directory containing the ninja binary(e.g., C:\Program Files\Ninja\). Click OK.
  6. Click OK twice more to exit the System Properties window.
  7. Confirm that Ninja is now accessible in a new command prompt by running ninja --version.

Configuring Visual Studio Code

  1. Launch Visual Studio Code.
  2. Select Open Folder... from the landing page or File>>Open Folder...
  3. Navigate to and select the folder created previously to open it in Visual Studio Code.

  1. Confirm that the directory structure looks as follows:

  1. Click the *.cpp file in the folder of src and modify the code in int CAN_Transmit(nxFrameCANFD_t *nxFrame){}.
  2. Open the command palette via Ctrl+Shift+P or View>>Command Palette...
  3. Search for and select Tasks: Run Task in the command Palette. This will pull up a list of the custom tasks available in the project.

  1. From the list, select CMake Generate Build Files.

  1. Confirm that the task runs and completes successfully in the Terminal window. There should be several new files in the project’s build/ directory, including a new bin/ directory for the build output.
  2. Open the Command Palette and select Tasks: Run Task again.
  3. Select Ninja.
  4. Confirm that the build task runs successfully and that there is now a *.so binary in the <project folder>/build/bin directory.

After the compile toolchain is created, just click Build to generate the so file.