Introduction
In the previous articles, we have demonstrated a number of programs, mostly written in Python, that run on an Edge device. However, there are times when we need to write programs in C/C++. It is easy to set up a C/C++ remote development environment on an Edge device such as e-RT3 Plus or Raspberry Pi. In this article, we demonstrate how to set up the C/C++ environment on an Ubuntu installed Edge device using Visual Studio.
Environment
Supported devices (OS)
- e-RT3 Plus F3RP70-2L (Ubuntu 18.04 32-bit) Edge controller of Yokogawa.
- Raspberry Pi 4 Model B (Ubuntu Server 20.04 32-bitοΌ
The armhf
architecture package runs on these devices.
Software requirements
Visual Studio Professional 2022 version 17.2.6
Getting started
The first step towards setting up a Visual Studio environment on the device is to install the gdbserver
package. To install the gdbserver
package on the device, run the following commands.
sudo apt update
sudo apt install g++ make gdb gdbserver zip
Note: By default, this package is installed on e-RT3 Plus.
Installing Visual Studio
Follow these steps to install Visual Studio:
-
Install the tool set required to set up the Linux environment.
Open Visual Studio Installer and install Linux and embedded development with C++.
For more information about Linux development with C++ in Visual Studio 2022, refer to the official documentation.
-
Configure the settings for connecting Visual Studio and the device by performing these steps:
-
To download the header to be used in IntelliSense, click Connection Manager > Remote Header IntelliSense Manager, select the device that you added, and then click Download.
Creating and debugging a project
Creating and debugging a project involves the following steps:
Creating a project
Follow these steps to create a project:
- Start Visual Studio and create a new project.
-
Specify the project type as C++ and Linux, select Console Application, and create a project by specifying the project name.
Configuring project settings
Follow these steps to configure project settings:
-
From the menu bar, select Project > {project-name} Properties.
From the Configuration drop-down list, select Debug.
-
From the Platform drop-down list, select ARM.
On the left pane, select General.
On the right pane, from the Remote Build Machine drop-down list, select the added device.
Click Apply.
-
On the left pane, select Debugging.
From the Remote Debug Machine drop-down list, select the added device.
From the Debugging Mode drop-down list, select
gdbserver
, and then click Apply.
Building and debugging a project
Follow these steps to build and debug a project:
-
After selecting Debug for Configuration and ARM for Platform, place a break point anywhere in the source code to build and run the program.
If the program stops at the break point, it indicates that the project is created successfully.
The output is displayed in the Linux console window.
Appendix
Adding source files
Follow these steps to add source files:
-
Right-click the project icon, and select Add > New Item.
The Add New Item dialog box appears.
-
Specify the file name, select the file type and then click Add.
Library links
Follow these steps to add library links:
- Open the Project properties.
-
On the left pane, select Configuration Properties > Linker > Input > Library dependencies, and then click Edit.
-
Enter the name of the library to be added.
The following image shows the scenario when
libm
is added.
Adding Include path
If you are using a header file that is available in a location other than the default location, you must configure the Include path settings.
-
From the Project Properties, navigate to C/C++ > General > Additional Include directories, and then click Edit.
-
Specify the directory path on device that includes the header file and click OK.
Top comments (0)