Search code examples
cvisual-studiocmdgtkgtk3

GTK+ with Visual Studio 2019


I am trying to install the GTK project on windows 10, and integrate it with Visual Studio in order to build an app with C.

After following their tutorial on installation , I have found myself at step 5 successfully, yet when I open visual studio to try and compile the "hello world" type code It doesn't recognise the header

#include <gtk/gtk.h>

and spits out the error

Error   LNK2019 unresolved external symbol 
gtk_window_set_child referenced in function activate

and

Error   LNK1120 1 unresolved externals  test    

so I went back to this page and followed the "Using GTK from MSYS2 packages" section, and again, no cigar.

I continued after these steps by following these instructions, and while the IDE now recognises the header and autocompletes, it seems that I'm still doing something wrong ...

The errors from the console are (after trying a few ways of executing the code)

D:\CDev\test>gcc -o test test.c `pkg-config --cflags --libs 
gtk4`
gcc: error: `pkg-config: No such file or directory
gcc: error: gtk4`: No such file or directory
gcc: error: unrecognized command-line option '--cflags'
gcc: error: unrecognized command-line option '--libs'

D:\CDev\test>gcc test.c
test.c:1:10: fatal error: gtk/gtk.h: No such file or 
  directory
     1 | #include <gtk/gtk.h>

Anyone got any ideas?

I'm wondering if this is relevant ...

{
   "cmake.configureSettings": {
     "CMAKE_TOOLCHAIN_FILE": "[vcpkg root]/scripts/buildsystems/vcpkg.cmake"
    }
}

but am hesitant to start messing around with cmake


Solution

  • remember:

    `
    

    rather than

    '
    

    in the cmd.

    PLEASE use this documentation if you come across this page!