After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 711772 - Fixing GTK+3 autotools build for Windows (cross-compiled with mingw-w64)
Fixing GTK+3 autotools build for Windows (cross-compiled with mingw-w64)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-11-10 12:32 UTC by Jehan
Modified: 2014-08-13 19:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for master. (4.46 KB, patch)
2013-11-10 12:32 UTC, Jehan
none Details | Review
Patch for gtk-3-8 (1.51 KB, patch)
2013-11-10 12:35 UTC, Jehan
none Details | Review
[orig. Jehan] Remove references to .def files (4.37 KB, patch)
2013-11-25 08:44 UTC, tarnyko
none Details | Review
Patch against master (5.64 KB, patch)
2014-08-13 10:16 UTC, Jehan
none Details | Review
Patch against master (5.64 KB, patch)
2014-08-13 12:04 UTC, Jehan
none Details | Review

Description Jehan 2013-11-10 12:32:11 UTC
Created attachment 259414 [details] [review]
Patch for master.

Hi,

I was trying to cross-compile GTK+ 3 for Windows on my Linux environment, and there are a few bugs in the current autotools files.
I have prepared 2 patches: one for gtk-3-8 and one for master branch.

Below are the details of the patches:

== Only on master ==

1/ since commit 019ad96479a9bafbf2948aa240dd57e2229f5985:
Generation rules of gdk.def from gdk.symbols have been removed. But remnants of the gdk.def dependency are still laying around in gdk/Makefile.am and gtk/Makefile.am in "if OS_WIN32" code.
As a consequence, we were getting this kind of error during the build:

make[4]: *** No rule to make target `gdk.def', needed by `libgdk-3.la'.  Stop.
make[4]: *** Waiting for unfinished jobs....
  CC     libgdk_3_la-gdkkeynames.lo

I'm not sure what exactly are the gdk.def and gtk.def files used for, but I will go with assuming it is now useless even on Windows, since it has been removed for Linux, so I deleted the relevant rules.

== Both master and gtk-3-8 ==

1/ I was getting a bunch of missing gdk_* references during linking in modules/input/ because of a missing library in LDADD.

--------
.libs/gtkimcontextime.o: In function `gtk_im_context_ime_set_use_preedit':
/home/jehan/prog/cross-compile/gtk+-master/modules/input/gtkimcontextime.c:868: undefined reference to `gdk_win32_window_get_impl_hwnd'
.libs/gtkimcontextime.o: In function `get_window_position':
/home/jehan/prog/cross-compile/gtk+-master/modules/input/gtkimcontextime.c:1135: undefined reference to `gdk_window_get_type'
/home/jehan/prog/cross-compile/gtk+-master/modules/input/gtkimcontextime.c:1138: undefined reference to `gdk_window_get_position'
/home/jehan/prog/cross-compile/gtk+-master/modules/input/gtkimcontextime.c:1141: undefined reference to `gdk_window_get_parent'
/home/jehan/prog/cross-compile/gtk+-master/modules/input/gtkimcontextime.c:1142: undefined reference to `gdk_window_get_toplevel'
[...]
---------

2/ gtk/updateiconcache.c must not #include "config.h".
As we can see in the gtk/Makefile.am (line 1727) updateiconcache is compiled in for the build machine, *not* for the host machine. But "config.h" has been generated f0001-Fix-autotools-build-for-cross-compiled-Windows.patchor the *host* machine! That is not a problem during a normal build, because host and build systems are the same. But when cross-compiling, it will result in bugs. For instance, cross-compiling with mingw-w64, I got these errors:

--------------------
make[4]: Entering directory `/mnt/dev/prog/cross-compile/gtk+-master/gtk/native'
  CC     native_update_icon_cache-updateiconcache.o
In file included from /usr/include/stdlib.h:314:0,
                 from ./../updateiconcache.c:21:
/usr/include/x86_64-linux-gnu/sys/types.h:65:17: error: two or more data types in declaration specifiers
/usr/include/x86_64-linux-gnu/sys/types.h:80:17: error: two or more data types in declaration specifiers
make[4]: *** [native_update_icon_cache-updateiconcache.o] Error 1
-----------------------

That was because gid_t and uid_t were #define-d in the config.h generated for mingw, but they were also defined in sys/types.h of my GNU/Linux os. So we got a double declaration error.

3/ Finally gtk/native/native-update-icon-cache would have a .exe when cross-compiling for win. I need to add a $(EXEEXT) to allow for every case, otherwise I get this error:

------------------------
make[3]: Entering directory `/mnt/dev/prog/cross-compile/gtk+-master/gtk/native'
  CCLD   native-update-icon-cache.exe
make[3]: Leaving directory `/mnt/dev/prog/cross-compile/gtk+-master/gtk/native'
  GEN    gtkbuiltincache.h
/bin/bash: ./native/native-update-icon-cache: No such file or directory
make[2]: *** [gtkbuiltincache.h] Error 127
------------------------
Comment 1 Jehan 2013-11-10 12:35:24 UTC
Created attachment 259415 [details] [review]
Patch for gtk-3-8

And the patch for the gtk-3-8 branch.
Comment 2 tarnyko 2013-11-10 13:28:46 UTC
Hello,

1) looks like a duplicate of :
https://bugzilla.gnome.org/show_bug.cgi?id=702860
https://bugzilla.gnome.org/show_bug.cgi?id=700445

2) and 3) fix an issue I use to work around currently, look good to me, will report back.
Comment 3 Jehan 2013-11-18 08:01:45 UTC
Hi Tarnyko,

Ok well I guess we can let the first bug being fixed in bug 700445 then.

For the other bugs though, I've just tested: the simpler patch for gtk-3-8 (attachment 259415 [details] [review]) works well with master too.
Could it be pushed to master and gtk-3-8?
Comment 4 tarnyko 2013-11-25 08:44:38 UTC
Created attachment 261386 [details] [review]
[orig. Jehan] Remove references to .def files

Hi,

I've split up your patch into parts. Regarding the first part about .def files, which works really well and is more complete than my proposal, please find attached a new version for which I had to add to remove a reference to "install-def-file" (maybe it is a new directive ?) to make it work with latest master.

I'll compare and report to :
https://bugzilla.gnome.org/show_bug.cgi?id=700445
and we'll try to solve this long-time issue.
Comment 5 lluixhi 2014-08-10 01:49:22 UTC
Well, while trying to compile gtk 3.12.2, I came across these patches, and I came further than I would have otherwise (also trying to cross-compile with mingw-w64), but I get an error where native-update-icon-cache tries (and fails) to link against the host system's libraries, when it should be linked against the build system's libraries.

native-update-icon-cache is also given the extension .exe, when it should have no extension..
Comment 6 Jehan 2014-08-13 10:16:30 UTC
Created attachment 283260 [details] [review]
Patch against master

Hi,

Thanks for testing this patch. I tested it again and indeed a lot of things changed since this time I proposed my original patch.

First of all, most of the .def generation issues seem to have been fixed in-between (there are still remaining references here and there to clean out, but they don't seem to be blocking the build. Bug 700445 is about these). So that slimmed down the new patch quite a bit.
You were right in saying that the native-update-icon-cache needed more work. And in particular I changed the fix. I don't remove the "config.h" include anymore because I realized this could be a problem for the installed gtk-update-icon-cache which uses the same source. Instead when building the native version, I generate a minimal config.h on the fly with only the strict minimum to have a working build.
Attached the new patch.

Please review/test.
For a finale working cross-compilable source, you will also want the patch from Bug 731013, also waiting for review.
Comment 7 Jehan 2014-08-13 12:04:58 UTC
Created attachment 283278 [details] [review]
Patch against master

Minor update of the patch.

For info: I tested also a native build. None of these changes break anything.
Comment 8 LRN 2014-08-13 18:07:11 UTC
This patch does not break anything for me.
Comment 9 Jehan 2014-08-13 19:12:06 UTC
As discussed on IRC with ebassi and LRN, patch committed:

commit 4376b4f705baec38e79449525e506bf4d28de4d2
Author: Jehan <jehan@girinstud.io>
Date:   Wed Aug 13 07:11:23 2014 +0000

    Fix the build of the native gtk-update-icon-cache when cross-compiling.
    
    As a noinst_PROGRAMS, the libtool generated for cross-compiling will be
    used, which will mess up the linking. Create a all-local target instead.
    Also ensure that building uses always a native version of the tool by
    specifying a GTK_UPDATE_ICON_CACHE automake variable.
    Finally "config.h" has been created to work for the target platform and
    causes problem when cross-compiling. So we temporarily generate a basic
    config.h which contains only the strict minimum.