Creating a C++ Beaglebone app with Visual Studio
This tutorial shows how to create a simple C++ project for the Beaglebone Black board using Visual Studio and VisualGDB 4.1 or later.
- Althrough the Beaglebone Black board contains a pre-loaded Linux image in its internal memory, it’s recommended to use an external micro-SD card and program it with the latest image from the Beaglebone site (e.g. using WinFLASHTool):Warning! If you are using Debian Stretch or later, you will need to rename the bbb-uEnv.txt file in the SD card to uEnv.txt. See this tutorial for a detailed explanation.
- Connect your Beaglebone Black board to a power source (e.g. via USB) and network. The LEDs will start blinking indicating the system activity:
- Open Visual Studio and begin creating new project with VisualGDB->Linux Project Wizard:
- As we are creating the simplest possible application, leave defaults on the first page and click “Next”:
- On the next page select “Create a new SSH connection” and enter the hostname of your Beaglebone board. By default Anstrom images use the “root” user with an empty password and Debian images use the “debian” user with “debian” or “temppwd” password:
- In this example we will setup our project so that it will be compiled directly on the Beaglebone board. It is slower than using cross-compiler, but simpler to achieve:
- When you press “Next” VisualGDB will ensure that your Beaglebone board contains all the necessary tools to build your project:
- At this point we don’t want to change the source disposition settings, so simply press “Finish” on the last page:
- VisualGDB will generate a Visual Studio project for you. Build it and see how the source files are transferred to the Beaglebone board and built there using GCC:
- Set a breakpoint in main() and press F5 to begin debugging. Once your breakpoint is hit, step over so that the “Hello, World” line is displayed in the output window and hover the mouse over sz to see its value:
- If building projects on Beaglebone is too slow for you, follow this tutorial to setup cross-compilation.