1

I started working in GTK with C and I'm very familiar with Microsoft Visual Studio. I use for compiling codeblocks or devC++ and even manual gcc command. But I wonder if the is a possibility to integrate GTK to the VS IDE because I know it's possible for C. I tried a lot but unfortunately with no success.

Thanks

PS: I have now VS 2017 RC but i can go back to VS Community 2015.

2 Answers2

3

This is a job for your build system. You should try a build system that generates project files for your IDE. For example, CMake, or even better, the meson build system, which is getting some attention on the GNOME and GTK community. Meson is easy to install: it only depends on python 3 and ninja (a faster replacement for make).

First, create a file named meson.build

project('gtk test', 'c')
gtk_dep = dependency('gtk+-3.0')
executable('myapp', 'myapp.c',
  dependencies : gtk_dep)

Then put your application code in myapp.c

#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
        GtkWidget *window;

        gtk_init (&argc, &argv);

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title (GTK_WINDOW (window), "Hello world !");
        g_signal_connect (G_OBJECT (window), "destroy", gtk_main_quit, NULL);

        gtk_widget_show_all (window);
        gtk_main ();

        return 0;
}

Finally, run meson in your Visual Studio environment to detect it. For that, follow the instructions at: https://github.com/mesonbuild/meson/wiki/Using-with-Visual-Studio

I never tried to use meson on Windows, but I'm pretty confident this should work. Feedback about the experience is welcome :)

Here are additional links to the meson documentation:

liberforce
  • 11,189
  • 37
  • 48
0

Check out the wingtk project to build the Gtk stack against msvc. From there you can just make a project file.

TingPing
  • 2,129
  • 1
  • 12
  • 15