February 22, 2019

Visual Studio 2015 and Linux (or Rasberry Pi)

I'm doing more coding for Linux (Raspberry Pi), for my hobby projects.  Most of Linux environments I have are headless, and using VIM is ok, but I prefer to use full featured IDEs such as Eclipse and Visual Studio for its conveniences.

I read both Eclipse and VS supports remote development/debugging but I haven't tried with Eclipse yet.  I recently tried with Visual Studio and it works pretty well.  There are many blogs and articles already how-to's -- so this posting is note to myself.

Windows Side

There will be 4 project types (templates): Blink (using GPIO), Console Application, Empty Project, Makefile Project.

Linux Side

It is assumed SSHd is installed and configured.

$ sudo apt-get install -y openssh-server g++ gdb gdbserver

For "Blink" sample project in VS, do this on RPi:

$ sudo apt-get install git-core
$ git clone git://git.drogon.net/wiringPi
$ cd wiringPi
$ sudo ./build

Test

  1. Run VS
  2. File > New > Project > Installed > Visual C++ > Cross Platform > Linux
  3. Select "Console Application (Linux)"
  4. It'll ask for SSH connection to Linux
  5. Back to the sample code, make sure the target platform is "ARM"
  6. Click on "Remote GDB Debugger"
On Linux side, you'll find "projects" directory under the configured user:

projects/
└── ConsoleApplication1
    ├── bin
    │   └── ARM
    │       └── Debug
    │           └── ConsoleApplication1.out
    ├── main.cpp
    └── obj
        └── ARM
            └── Debug
                └── main.o


"ConsoleApplication1.out" is the binary.

Please read the links in References to find more info.

VS Connection Manager

To add, edit connections:
Tools > Options > Cross Platform > Connection Manager

For existing project, go to Project Properties to change existing connections and other settings.

Remote Debug & Bring up Terminal

Click on "Remote GDB Debugger", and from top menu, Debug > Linux Console.

Set Command Line Parameters

  1. Right click on Project (not Solution), and bring up Properties
  2. Configuration Properties > Debugging
  3. And on right pane, find "Program Arguments"

 

 References

No comments: