Page 1 of 1

Cross-compiling for Windows

Posted: Fri Apr 05, 2019 3:01 pm
by Caedo
In an effort to make use of WSL, I've been looking into cross-compilation for Windows from Ubuntu. To that end, I'm using the 'mingw-w64' apt package. I've gotten configure to run through with --host=x86_64-w64-mingw32 (and a corresponding --prefix, which doesn't seem to make a difference), but run into a problem when making the project: It's including the wrong headers. In this case, the issue occurs in utility/astring.c after a chain of includes:

Code: Select all

  CC       astring.lo
In file included from /usr/share/mingw-w64/include/time.h:293:0,
                 from shared.h:24,
                 from fcintl.h:26,
                 from astring.c:68:
/usr/include/x86_64-linux-gnu/sys/timeb.h:21:10: fatal error: features.h: No such file or directory
 #include <features.h>
compilation terminated.
Makefile:740: recipe for target 'astring.lo' failed

The included time.h appears to be the correct one. However, for some reason, it can't find the right sys/timeb.h, but instead uses the linux one, which then needs other linux headers (that don't exist in the mingw-w64 environment). One thing to note here is that the regular include directory is /usr/x86_64-w64-mingw32/include, not /usr/share/mingw-w64/include. This may be (from my unprofessional assessment) why it's then looking into the wrong directories.

When I tried replicating the issue by making my own tiny script including time.h, the correct headers are being included (at least according to the preprocessor output). I've previously experienced a similar error in the luasql files with string.h (which I've circumvented by disabling fcdb); that one also went away when using a dedicated script and running it through x86_64-w64-mingw32-gcc.

For reference, this is my configure setup:

Code: Select all

./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 --disable-nls --enable-client=gtk3.22 --enable-fcmp=no --enable-fcdb=no

When adding --[old]includedir=/usr/x86_64-w64-mingw32/include, the issue persists.

Anyone got any ideas on how to fix this issue?

Re: Cross-compiling for Windows

Posted: Sat Apr 06, 2019 5:21 pm
by cazfi
In S3_0 or master, see windows/installer_cross/ I should have scripts for older branches still available if you need them.

Re: Cross-compiling for Windows

Posted: Sat Apr 06, 2019 5:45 pm
by cazfi
My guess would be that the wrong include path gets added by pkg-config finding build system version of some package. (I don't know where you are expecting to get windows versions of all the freeciv dependencies)