Objectives : compile a C/GTK+3 application under Linux, and produce a valid Windows© binary.
We have a C application using GTK+ 3 as its graphical toolkit :
As the GTK+ 3 Windows binaries now have an official distribution, we will be able to use to create a Windows version of our application, without modifiying the source code nor having a Windows box available.
- Install the GCC compiler for Windows (namely MinGW) :
apt-get install mingw32
(ps : Create a folder named "gtk3-win32" where you want, put the ZIP archive therein and extract it with :
- Adapt GTK+ to its location :
In a terminal, move to the "gtk3-win32" folder you just created. If you extracted it to "/opt/gtk3-win32" e.g. :
then do :
find -name '*.pc' | while read pc; do sed -e "s@^prefix=.*@prefix=$PWD@" -i "$pc"; done
- We will tell "pkg-config" to locate GTK+ libraries in our custom path. If you extracted to "/opt/gtk3-win32" e.g. :
We are ready to compile an sample C source ! Let's use a command in this style :
i586-mingw32msvc-gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0`
A new executable should have been created if everything went well.
It won't run on our Linux system, because it's targeting Windows !
- Create a folder containing the binary and the Windows .dll files. If you extracted to "/opt/gtk3-win32" e.g. :
cp executable.exe ~/distri
cp /opt/gtk3-win32/bin/*.dll ~/distri
- Here we go ! Transfer this folder to a Windows box. Double-click on the executable and...
Well done !