0

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!

  • 1
    MSYS2 greatly simplifies C/C++ software development for windows with its package manager and ports of Linux utilities. The programs you compile with MSYS2 can be copied out of MSYS2 (along with the required DLLs) and run as a standalone application on the end user's computer. If you really want to make your life harder by not using MSYS2, you should at least attempt to do it on your own and then ask a specific question when you encounter a specific error message you cannot solve. – David Grayson Jan 27 '19 at 00:51
  • Your specific message tells me that it is not able to find the references to all the gtk+ functions I have called allthough I link my program with every (!!) library in my msys/mingw64/lib folder. –  Jan 29 '19 at 11:24
  • @David Grayson If I download the GTK+ library with MSYS2 and link my app with all libraries located in the lib/ folder, nothing happenes. There are still all the references missing like if i linked with nothing. But if I use the precompiled libraries of this guy at https://www.dropbox.com/sh/8d1qbh5dsp044on/AAB63l5I1eZks-QqjH6HXUJHa and compile my program with _-m32_ for 32bit, everything works as expected! What am I doing wrong? –  Jan 30 '19 at 15:08
  • I think you may be confused with having a directory included in the link directive with -L which may have many libraries in it and actually linking with a specific library with the -l (that is el). Just because there are a lot of libraries in a directory doesn't mean you're linking with all of them. – sorton9999 Jan 30 '19 at 15:12
  • Oh, sorry, I forgot to mention that I am using a Makefile looking for all *.a files located in my library folder and using them on linking time like an object file. And as I already said, with the precompiled libraries everything worked as expected. Only the libraries from MSYS2 do not work properly or stand-alone or whatever. –  Jan 30 '19 at 15:35
  • Have you considered installing Linux on your development machine? It might make your developer's life more enjoyable, if you care about GTK3 – Basile Starynkevitch Jan 30 '19 at 17:21
  • I already have Ubuntu installed on a USB device, but will I be able to compile my program with GTK+ for windows? Under Linux? I know, there are cross compilers for windows targetting under Linux, but is there also a win64 version of GTK+ for Ubuntu? –  Jan 31 '19 at 08:04

1 Answers1

-1

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.

David Grayson
  • 84,103
  • 24
  • 152
  • 189