This tutorial shows how to develop for Raspberry PI using a cross compiler in Visual Studio.
Before we begin, ensure that VisualGDB 3.0 or later is installed.
- Start Visual Studio. Go to File->New->Project and select VisualGDB->Linux Project Wizard. Choose a name and location for the project and press ‘OK’ when done.
- Choose ‘Create a new project’ and press on ‘Next’.
- Choose ‘Build the project locally with a cross-compiler. For the cross-toolchain choose ‘Raspberry PI’.
- Choose the toolchain to be downloaded and installed.
- Accept the toolchain license and press on ‘Install’. The toolchain will then be downloaded and installed.
- Once the installation of the toolchain completes, choose the raspberry board for the deployment computer. Create a new SSH connection for it.
- Choose the hostname or ip of the board together with the user name and password. Here we use the default user name pi and password raspberry. It is recommended to check the “setup public key” checkbox, so that VisualGDB will automatically generate an public/private keypair, store it in your Windows account’s key container and setup the Raspberry PI box to use it. Press on ‘Create’ to make the connection. If you don’t enable public key authentication, VisualGDB will remember your password for this connection. The stored passwords are encrypted using a key stored in your Windows account. Thus, the password will only be available once you login using your Windows account.
- Once the connection has been made, press on ‘Finish’ in the wizard.
- Build the project. VisualGDB will use the local toolchain to build it.
- Set a breakpoint in the main function. Start debugging. VisualGDB will deploy your executable to the Raspberry PI board.
- The execution will pause at the breakpoint.
- If you want to add support for additional headers/libraries, copy them from Raspberry PI to the corresponding directory under <toolchain path>\arm-linux-gnueabihf\sysroot and update flags.mak to add new include directories and libraries.