Search by Tags

Build and Run your First C Application


Your progress



When it comes to Linux development, it is possible to choose several IDEs, workflows and programming languages for development. Aiming to simplify your development experience Toradex provides TorizonCore IDE integration with Visual Studio Code for Windows and Linux PCs, and Visual Studio for Windows PCs.

In this module you will:

  • Use the Visual Studio IDE.
  • Cross-compile your application using the Torizon Microsoft Environment plugin for Visual Studio.
  • Deploy it to the target module and debug it remotely from your development PC.

Note: support for a more complex workflow on Visual Studio will be presented to you at the end of the quickstart guide, as well as support for other programming languages on Visual Studio Code. If you have a Linux PC for development, you can also try the quickstart guide for Torizon with Linux selected as Development PC OS.

Attention: the Toradex Microsoft Environment is a project under Toradex Labs and is still in alpha state. In case any bug is experienced while going through the guide, you are welcome to provide feedback on the Toradex Community.

Typographic Conventions


For this Getting Started Guide:

  • Development computer with Windows 10 Pro / Enterprise / Education.
  • Successfully completed the previous lesson from this guide.

For this lesson:

  • Visual Studio 2017 or 2019 installed with Visual C++ for Linux Development extension (if you haven't already installed it you can add it by launching the Visual Studio Installer and modifying your current setup, or download here).
  • Toradex hardware and computer on the same network.

Note: Carefully read this module's cover page clicking on "Module 2: First Steps with Torizon" on the left menu bar before starting this lesson.

Warning: when installing visual studio make sure you select the following options for the correct operation of the Torizon C/C++ Application development add-in:

  • Select Desktop development with C++

    Select Desktop development with C++

  • Select Linux development with C++

    Select Linux development with C++

Step 1

To be able to use the Torizon Microsoft Environment, head to the Visual Studio Marketplace, download and install Torizon C/C++ Application development.

Warning: The extension is available for Visual Studio 2017 and 2019 only!

Check that the installation was successful by opening the extension list under Tools > Extensions and Updates:

  • Torizon Microsoft Environment Extension

    Torizon Microsoft Environment Extension

Step 2

The extension provides some windows and toolbars but they are hidden by default. You can show the device list by selecting View > Other Windows > Torizon devices from the menu bar in Visual Studio.

Once it shows up, you can detect devices through serial port or network. In this guide we will use the network device detection.

  • Toradex Devices Window

    Toradex Devices Window

Step 3

To add your device to this list, select "Detect device on the network" and set your board's IP or hostname as found out on the previous lessons:

  • Adding new devices

    Adding new devices

Note: Remember that the credentials are username: torizon and password: torizon

After adding the device the board will reboot. Refresh the device on the list and see the collected data:

  • Toradex Devices Window Refreshed

    Toradex Devices Window Refreshed

Step 4

Enable the Torizon toolbar on Visual Studio selecting Tools > Customize, scroll down the list, select "Torizon Toolbar" and hit Close:

  • Torizon Toolbar

    Torizon Toolbar

Step 5

Create a New Project and select Torizon C/C++ Application from the Visual C++ category:

  • New Project Dialog

    New Project Dialog

Step 6

Select the platform you want to use for running your application. Platforms are base container images which provide different sets of features.

Select Debian Buster slim and add "torizon" to username.

  • Platform choice dialog

    Platform choice dialog

Step 7

Open Debug > Linux Console so you can see the application output.

Step 8

Open the solution explorer menu and change the main.cpp file to:

#include <cstdio> int main() { int var = 1, i; for(i = 0; i < 5; i++){ var = 2*var; printf("Loop %d - var=%d", i, var); } return 0; }

Step 9

To build your sample application, select Build > Build Torizon Application from the menu bar. When you build an application for the first time, it will take a while.

Note: On the first build it may take up to 10 minutes. Depending on your PC configuration, you may occasionally see "not responding" messages which can be ignored.

Step 10

When the build is finished, deploy it to target device selecting Debug > Deploy and debug Torizon and select which device to send the application to:

  • Device deployment

    Device deployment

Note: This step also takes a while since the module has to load the container.

Step 11

To debug your application, insert breakpoints to the left of the line number. For instance, insert a breakpoint relative to the printf command (line 7).

  • Breakpoint set

    Breakpoint set

Now, when you select Debug > Deploy and debug Torizon it is possible to use Visual Studio debugging features to step through your code.


Where do I find more information about the Torizon Microsoft Environment?