The Visual Studio Linux Features do not inherently support cross-compiling on a Windows PC. Instead, Visual Studio will upload the the source files to the ComfilePi, and use the ComfilePi's toolchain to build the executable. The executable is then executed on the ComfilePi, and the Visual Studio Remote GDB Debugger attaches to it.
This method can be used for much more than console applications, including Qt, GTK+, and even OpenGL to name a few. The demonstration that follows illustrates that development process for very simple GTK+ GUI application.
Download the source code for this demonstration.
#include <gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); printf("Running gtk_main\n"); gtk_main(); printf("Exiting\n"); return(0); }
There are many Intellisense errors because Visual Studio can't find the ComfilePi's header files.
To allow Visual Studio access to the ComfilePi's include folders, we will expose them through a Samba share.
sudo apt-get install samba
on the ComfilePi./usr
, providing read-only access to /usr/include
and /usr/lib
, by editing the /etc/samba/smb.conf
file as shown below[usr] path=/usr browseable=yes read only=yes valid usr=pi public=yes hide dot files=yes follow symlinks=yes wide links=yes unix extensions=no
See the smb.conf reference for more information.
sudo /etc/init.d/smbd restart
Open the Project's Properties window.
\\{ComfilePi_IP_Address}\usr\lib\gcc\arm-linux-gnueabihf\4.9\include-fixed; \\{ComfilePi_IP_Address}\usr\lib\gcc\arm-linux-gnueabihf\4.9\include; \\{ComfilePi_IP_Address}\usr\include\arm-linux-gnueabihf; \\{ComfilePi_IP_Address}\usr\include\arm-linux-gnueabihf\c++\4.9; \\{ComfilePi_IP_Address}\usr\include\c++\4.9; \\{ComfilePi_IP_Address}\usr\include;
These includes are general C/C++ includes that will likely be needed for any C/C++ project.
\\{ComfilePi_IP_Address}\usr\include\gtk-2.0; \\{ComfilePi_IP_Address}\usr\lib\arm-linux-gnueabihf\gtk-2.0\include; \\{ComfilePi_IP_Address}\usr\include\gio-unix-2.0\; \\{ComfilePi_IP_Address}\usr\include\cairo; \\{ComfilePi_IP_Address}\usr\include\pango-1.0; \\{ComfilePi_IP_Address}\usr\include\atk-1.0; \\{ComfilePi_IP_Address}\usr\include\pixman-1; \\{ComfilePi_IP_Address}\usr\include\libpng12; \\{ComfilePi_IP_Address}\usr\include\gdk-pixbuf-2.0; \\{ComfilePi_IP_Address}\usr\include\libpng12; \\{ComfilePi_IP_Address}\usr\include\harfbuzz; \\{ComfilePi_IP_Address}\usr\include\glib-2.0; \\{ComfilePi_IP_Address}\usr\lib\arm-linux-gnueabihf\glib-2.0\include; \\{ComfilePi_IP_Address}\usr\include\freetype2;
These includes are specific to this project due to the fact that it is using Gtk+. They can be determined by running pkg-config –cflags gtk+-2.0
on the ComfilePi.
The project no longer shows any Intellisense errors.
`pkg-config –cflags gtk+-2.0`
to the C/C++–>Command Line–>Additional Options setting, and add `pkg-config –libs gtk+-2.0`
to the Linker–>Command Line–>Additional Options setting.