Tutorial: Cross-compiling C++ projects for Beaglebone

In this tutorial we will show how to use a cross-toolchain to quickly build and debug Beaglebone projects from Visual Studio using VisualGDB 4.1 or later. Before you begin with the cross-compiler it is recommended to follow this tutorial to create a basic project using direct compilation on Beaglebone.

  1. Start Visual Studio. Go to File->New->Project and select VisualGDB->Linux Project Wizard. Specify the name and directory for your project: 01-newprj
  2. On the first wizard page select “Application” and click “Next”:02-app
  3. The second wizard page allows switching between compiling your source code on the Beaglebone board and using a cross-compiler hosted on Windows. Select “Build the project locally” and then pick “Beaglebone” from the cross-toolchain list:03-toolchainEnsure that the toolchain you download matches the Beaglebone image you are using. You can find out the compatible images on the Beaglebone toolchain page.
  4. If you don’t have the toolchain installed yet, VisualGDB will automatically download and install it for you:04-install
  5. Select your Beaglebone board in the “Deployment computer” field: 05-toolchain-done
  6. If you have just downloaded the toolchain it is recommended to synchronize the sysroot. This will take a few minutes, but will ensure that both the toolchain and your device are using the same headers and libraries and that the binaries produced by the toolchain will be 100% compatible with your device. Click “Synchronize headers and libraries” and synchronize with default settings:06-sysroot
  7. Once the synchronization is done, click “Finish” to have your project created. Build it with Ctrl-Shift-B. Note that the building with a cross-toolchain is much faster then building it on Beaglebone:07-build
  8. Put a breakpoint in main() and start debugging by pressing F5. Once the breakpoint is hit you can use the common debugging techniques (e.g. stepping or viewing memory) to debug your program:08-break
  9. When done debugging, right-click on the project in Solution Explorer and select “VisualGDB Project Properties”. The VisualGDB Project Properties window allows changing various settings related to building and debugging (e.g. specifying additional libraries or resynchronizing the sysroot):09-properties