Cant compile basic example with Gtk 3 in Msys2 comand window

Steps to reproduce

I’m trying to use GTK from MSYS2 packages, so follow the instrucctions from : The GTK Project - A free and open-source cross-platform widget toolkit

Step 1. Download the MSYS2 installer that matches your platform and follow the installation instructions.

Step 2. Install GTK3 and its dependencies. Open a MSYS2 shell, and run:

pacman -S mingw-w64-x86_64-gtk3

Step 3. (optional): If you want to develop a GTK3 application in Python, you need to install the Python bindings.

If you develop in Python 3:

pacman -S mingw-w64-x86_64-python3-gobject

Step 4. Install the build tools. If you want to develop a GTK3 application in other languages like C, C++, Fortran, etc, you’ll need a compiler like gcc and other development tools:

pacman -S mingw-w64-x86_64-toolchain base-devel

Step 5. next, I try the basic prg( example-1.c ) from : Gtk – 3.0: Getting Started with GTK

gcc pkg-config --cflags gtk+-3.0 -o example-1 example-1.c pkg-config --libs gtk+-3.0

NOTE 1 : when I run the command above, I get this message :

*Package gtk±3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing gtk+-3.0.pc' to the PKG_CONFIG_PATH environment variable Package 'gtk+-3.0', required by 'virtual:world', not found Package gtk+-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing gtk±3.0.pc’ to the PKG_CONFIG_PATH environment variable Package ‘gtk±3.0’, required by ‘virtual:world’, not found hellow.c:1:10: fatal error: gtk/gtk.h: No such file or directory 1 | #include <gtk/gtk.h> | ^~~~~~~~~~~ compilation terminated.*

NOTE 2 : to solve the previous problem, i use this bash( gtk3-run-example.sh ), attached also to this email.

#!/bin/sh

# srcdir=`dirname $0`
# echo "directorio : $srcdir"

export PKG_CONFIG_PATH=/mingw32/lib/pkgconfig

gcc `pkg-config --cflags gtk+-3.0` -o example-1 example-1.c `pkg-config --libs gtk+-3.0`

Current behavior

The previous command only generates a bunch of errors, that I attach as "output-error.log"

NOTE : I need to know if I miss some step or what, thanks.

Version information

  • GTK version : 3
  • OS version : Windows 10

Additional information

One issue might be that you’re using an MSYS2 shell.

Most packages for MSYS2 are either mingw-w64-x86_64-* or mingw-w64-i686-* packages, meaning they’re compiled for the Windows compatibility layer of MSYS2, and those are meant to be accessed from either the MinGW 32-bit or MinGW 64-bit shell.

The MSYS2 shell has access to the UNIX emulation layer (the packages in the msys repo, without mingw- prefix names, that install to C:\msys64\usr\...), but without the Windows packages in C:\msys64\mingw32\ or C:\msys64\mingw64\ hierarchies being enabled.

If you run a MinGW shell, you should find that the appropriate pkg-config paths and etc. are already set up, and everything just works.

Unfortunately I can’t access any of your uploaded files, so we’ll have to stick with my best guess. If it doesn’t solve the problem, you may want to upload output/scripts as a GitHub Gist or something similar, and post a link instead.

Or, just embed the relevant text directly in your posts, if it’s of reasonable length. (We probably don’t need all of the output, just the input and the error message(s) at the end of the run.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.