user10251509
user10251509

Reputation:

Using GTK+ without MSYS2

Dear programmers and developers,

I really want to try out GTK+ 3 on windows. Therefore, I read the official GTK+ download explanations at https://www.gtk.org/download/windows.php and installed everything with MSYS2.

Now I have a lot of files in my mingw64 subdirectory of my MSYS2 folder.

The question: How do I include all of them right? How do I link to GTK+ with all it's dependencies? I know there is a magic pkg-config attribute for the Linux C/C++ compiler, but unfortunately I am really not interested in compiling my projects in MSYS2. I am willing to use a simple MinGW (64) compiler.

Can anybody help me using the .a's, .h's and .dll'a that MSYS2 generated with a simple MinGW 64bit compiler for a stupid C++ project?

It would make me extremely happy!

Darth Moon

€edit: I actually have downloaded a precompiled GTK+ version from https://www.dropbox.com/sh/8d1qbh5dsp044on/AAB63l5I1eZks-QqjH6HXUJHa. Unfortunately, it is only 32bit but I will soon try to compile the whole GTK+ project on myself like this guy at https://github.com/Wesley-Chan/GTK-for-Windows did.

But if anybody has any idea how to build GTK+ in a smooth way under windows (especially for 64bit), please let me know! I really enjoyed the GTK+ example application and I really want to make my own ones!

Upvotes: 0

Views: 1197

Answers (1)

David Grayson
David Grayson

Reputation: 87486

I was able to successfully compile a GTK3 program in a MinGW 64-bit shell from MSYS2. First I installed the GTK3 package:

pacman -S $MINGW_PACKAGE_PREFIX-gtk3

Then I compiled the first example program from this page using the following command:

gcc test_gtk.c $(pkg-config gtk+-3.0 --cflags --libs)

Then I ran ./a.exe and it created a window.

If you are getting "undefined reference" linker errors, it means your Makefile is not linking your program to all of the correct libraries, or the order of the inputs to the linker is wrong.

Upvotes: -1

Related Questions