Creating executables for Windows from a Linux box

3 March 2010 at 3:34 pm Leave a comment

When writing a program, especially a graphical one, you may feel some compassion towards Windows users and wonder whether it would be possible to give them a chance of using it. Famous toolkits like GTK and Qt provide good support for Windows and an abstraction layer for OS-dependent vital functions, so it becomes easier to write OS-independant code.

Next you need a cross-compiler: it’s just a compiler, except that instead of creating executable files you could run, it creates executables in another format (e.g. Win32 .exe files). But since Windows is very different from GNU/Linux, some code or one of its dependencies has to use Windows-specific functions: so you need source headers, and maybe additional libraries.

MinGW aims at providing all of this: a compiler, a linker and other necessary utilies, headers and libraries for Windows basic functions… Standard distributions include a package for installing MinGW. Mine is ArchLinux, and the needed package is mingw32-gcc. If you are using autoconf, there is then an easy way of using the cross-compilation tools instead of the traditinoal ones.

Suppose the name of the cross-compiler is i486-mingw32-gcc, as it is the case with ArchLinux: then the option --host=i486-mingw32 will tell the configure script to use i486-mingw32-xxx programs instead of xxx. It allows installing all GTK libraries as DLLs, and compiling a GTK program as a .exe binary. I have not yet tested the resulting file on a real Windows system, but it works under Wine.

When testing with Wine, you need to make the needed DLLs accessible: this can either be done using the drive_c directory tree which holds programs installed under Wine, or by including in the PATH variable the folder containing the binaries and DLLs compiled by MinGW, for example /usr/i486-mingw32/bin (this should be done in $HOME/.wine/system.reg, using Wine conventions for path names).

Entry filed under: software. Tags: , , .

Changing default applications, for developers Mathkaba : my tool for managing bibliography

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Pages

Categories


%d bloggers like this: