Running a GTK+ application built with MSYS2 by just double clicking it


I have a simple window application, built with MSYS2, which I want to be able to run outside of the MSYS2 MinGW shell, just by double-clicking on the application.

The problem is that when I want to run the application it must be though the MSYS MinGW prompt otherwise it returns an error.

The code execution cannot proceed because libgio-2.0-0.dll was not found. Reinstalling the program may fix this problem

I tried including (by copying the files to the location of my exe) libgio-2.0-0.dll and more errors appeared saying libraries were missing. I included those files too. I have shown the files I included below:


In the end an error appears saying:

The application was unable to start correctly (0xc000007b).  Click OK to close the application.

I found what the error message means:

That particular error code refers to an invalid image format. However, what the error code usually means is that you are trying to run a program that is intended to work with a 64 bit Windows operating system, but that you only have a 32 bit OS.

However it does not help as I am running an x64 computer. The DLL are x64 as well as the exe. says GTK+ depends on some libraries and apart from what I have done above I cannot think of any solution and cannot find any documentation on what dependencies to include in order to not run it through the MSYS prompt.

So what do I need to do to get my window working? The application is fine there is a problem with the dependencies.

Secondly what are the dependencies I need to include (or have I listed all of them in which case what is going wrong with my window) for the script I gave?

And finally is there an easier way than what I am trying to do to get all the necessary dependencies?

asked on Stack Overflow Oct 20, 2017 by Simon • edited Oct 23, 2017 by liberforce

2 Answers


The system needs to be able to find the shared libraries. On a Linux system, this is through the linker, usually ld. The configuration for where to find them lies in /etc/ and /etc/

Now on Windows, this doesn't exist. That's why the environment variable PATH commonly is used for that, and sometimes modified by installers. But changing the PATH for every program is annoying and forbids relocation (moving the whole app directory and running the app from elsewhere). So you may just create an empty directory, create a bin directory in it, and copy your application binary and the GTK+ libraries there. That should work because the current directory is searched before the PATH variable on Windows.

So what you have done is correct. The problems you have are similar to app redistribution, ie. gathering the necessary bits to distribute a software on another computer. This isn't the most documented part on the GTK+ website unfortunately. Have you tried with a an application that doesn't use the GtkApplication class?

answered on Stack Overflow Oct 23, 2017 by liberforce • edited Oct 23, 2017 by liberforce

I fixed it by including library through command line like this.

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

and run it using mingw64.exe that comes with MSYS2 installer

answered on Stack Overflow Mar 15, 2018 by HaSeeB MiR • edited Mar 15, 2018 by HaSeeB MiR

User contributions licensed under CC BY-SA 3.0