Search code examples
c++windowscmakeheadermsys2

msys2 and headers in the 'wrong' place


Ok, so, I'm trying to build a third party library with msys2 and I've run into a problem with a few headers, such as gtk.h; the library I'm trying to build expects this to be located via #include <gtk/gtk.h>.

Now, experience on Linux tells me that would be correct under a normal linux environment; however, in the case of gtk, it seems it would have to be gtk-3.0/gtk/gtk.h, which seems like an error in msys to me - is there some sort of selection step I've missed in setting up my msys2 environment? Like the 'eselect' system under Gentoo, something like 'pselect gtk-3.0' that would create a linked directory to gtk-3.0/gtk just called gtk?


Solution

  • Assuming that you have installed the mingw-w64-i686-gtk3 package with pacman and that you are running in a MinGW 32-bit shell (MSYS2 has three different flavors of shell that use different toolchains), you can run this command to get the required compile flags for GTK3:

    pkg-config gtk+-3.0 --cflags
    

    Most build systems have some kind of support for calling pkg-config. It is basically the standard way to get information about your dependencies.

    When it's time to link your program, you should replace --cflags in the comand above with --libs.