[Crossfire-wiki] [Crossfire DokuWiki] page added: user:cavesomething:crosscompiling_for_windows

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Wed May 19 19:52:11 CDT 2010


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2010/05/19 19:52
User        : cavehippo
Edit Summary: created

This assumes that you want to cross-compile a client for use on windows from a *nix system, and will describe the steps to do so.

This is in no way a sensible or correct way to do this, I'm merely describing an approach that works.

Parts of this are taken from [[http://live.gnome.org/GTK%2B/Win32/Apps]] which is a helpful starting point 

=== Setup build environment ===

You want mingw32. If you are using a debian-like system, then the packages are mingw32, mingw32-binutils & mingw32-runtime
Note that the version of mingw32-binutils that ships with lenny (2.18.50) seems to be broken, so go with the version from squeeze (or later) (ie, 2.20+)

This will install lots of starting tools in /usr/i586-mingw32msvc - if you use the equivalent packages from another distro, it may be somewhere else, just find out where, and use that whenever I refer to this location.

In order to correctly use many libraries, pkg-config is used, when compiling with mingw, it will try to run i586-mingw32msvc-pkg-config. You will need to set up an executable shell script somewhere in your path with this name.
give it the following contents:
<code>
#!/bin/sh
PKG_CONFIG_LIBDIR=/usr/i586-mingw32msvc/lib/pkgconfig \
PKG_CONFIG_PATH=/usr/i586-mingw32msvc/lib/pkgconfig pkg-config $*
</code>


=== Get the GTK libraries ===
You will need the gtk libraries, fortunately there is a all-in-one bundle available from [[http://www.gtk.org/download-windows.html]]
unzip this somewhere convenient.

Now, there are a number of subfolders that have just been extracted.
Everything in bin should go to /usr/i586-mingw32msvc/bin
Everything in lib should go to /usr/i586-mingw32msvc/lib
Everything in include should go to /usr/i586-mingw32msvc/include

Everything else you can ignore.

=== Other Libraries ===
There are lots of other libraries you need, I don't even know what a minimal set is any more.

At a minimum, you will need 
  * libglade
  * pthread - you probably want to use pthreadGC2.dll 
  * SDL
  * SDL_image
  * libpng1.2 (As distinct from 1.4 which the gtk bundle gave you)
  * libcurl

Remember to get both the developer packs and the dll files for each of these, sometimes they are in two separate downloads.

in any case:
  * dll files belong in /usr/i586-mingw32msvc/bin (and in gtk-v2/src a bit later, see below)
  * .a or .lib files belong in /usr/i586-mingw32msvc/lib
  * .h files belong in 

As a special case, sdl_config (from the sdl package) goes in bin.

Also, you will need a copy of SDL.dll in the client directory, this is because the configure script runs an SDL test program which fails if the dll isn't available.

=== Tidying up ===

some special command line voodoo:

<code>
cd /usr/i586-mingw32msvc
sed -i 's|^prefix=.*$|prefix=/usr/i586-mingw32msvc|g' lib/pkgconfig/*.pc
cd ./lib
for f in *.lib; do mv $f lib${f%%lib}a; done
</code>

After all this, be sure that you can read all of the files under /usr/i586-mingw32msvc otherwise compilation will break.

=== Configuring ===

You will need to create a configure script if you don't have one already, try running
<code>
./autogen.sh --host=i586-mingw32msvc --with-sdl-exec-prefix=/usr/i586-mingw32msvc
</code>

if you already have a configure script, then you can run it directly:
<code>
./configure --host=i586-mingw32msvc --with-sdl-exec-prefix=/usr/i586-mingw32msvc
</code>

either way, you should end up with a configuration summary that looks like this:

<code>
configure: Configuration summary....                                                                                          
configure:                                                                                                                    
configure:   Paths                                                                                                            
configure:     prefix default value                 /usr/local                                                                
configure:     exec_prefix default value            ${prefix}                                                                 
configure:     Will put executables in              /usr/local/bin                                                            
configure:     Will put config in                   ${prefix}/etc                                                             
configure:     Will put data in                     .                                                                         
configure:                                                                                                                    
configure:   Build options                                                                                                    
configure:     Will build GTK2 client?              yes                                                                       
configure:     With OpenGL renderer?                no                                                                        
configure:     With SDL renderer?                   yes                                                                       
configure:     Will build sound server?             no                                                                        
configure:                                                                                                                    
configure:   Scripting options                                                                                                
configure:     Will include lua interface?          no     
</code>

You have a Makefile now, so run make.

=== Compilation ===

You may well see errors here, bodge the source code until they go away.

=== Linking ===
All being well, it will compile the c code and fail dismally in the linker step.

That's ok, we didn't pass the right configure-time options to link it properly anyway.

go to gtk-v2/src and run
<code>
i586-mingw32msvc-gcc -mwindows -g -O2 -mms-bitfields -Wall   -o crossfire-client-gtk2.exe about.o account.o config.o image.o info.o inventory.o keys.o main.o map.o magicmap.o menubar.o metaserver.o opengl.o pickup.o png.o sdl.o skills.o sound.o spells.o stats.o ../../common/libcfclient.a ../../common/libgdk_pixbuf-2.0.dll.a ../../common/libglade-2.0.dll.a ../../common/libpango-1.0.dll.a ../../common/libgtk-win32-2.0.dll.a -lpthreadGC2 -lgdk-win32-2.0 -latk-1.0 -lpangoft2-1.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lfreetype -lfontconfig -llibgobject-2.0 -lgmodule-2.0 -llibglib-2.0   -lwsock32 -lwinmm -lpng12 -lz -lm  -llibcurl -liberty -lgailutil -lSDL -lSDL_image -lmingw32 -lSDLmain -mwindows libSDL.dll.a
</code>

This will require you to put 
  * libgtk-win32-2.0.dll.a
  * libgdk_pixbuf-2.0.dll.a
  * libglade-2.0.dll.a
  * libpango-1.0.dll.a
  * libgtk-win32-2.0.dll.a
  * libSDL.dll.a
in your common/ directory beforehand. All these files should already be in /usr/i586-mingw32msvc/lib somewhere.

That should give you a .exe file.

Now grab lots of dll files from /usr/i586-mingw32msvc/bin and put them in gtk-v2/src

Start with this list:

  * libcurl.dll
  * pthreadGC2.dll
  * zlib1.dll
  * freetype6.dll
  * libexpat-1.dll
  * libglade-2.0-0.dll
  * libgtk-win32-2.0-0.dll
  * libpng12-0.dll
  * libpng14-14.dll
  * iconv.dll
  * libfontconfig-1.dll
  * libglib-2.0-0.dll
  * libpango-1.0-0.dll
  * SDL.dll
  * libatk-1.0-0.dll
  * libgdk_pixbuf-2.0-0.dll
  * libgmodule-2.0-0.dll
  * libpangocairo-1.0-0.dll
  * libcairo-2.dll
  * libgdk-win32-2.0-0.dll
  * libgobject-2.0-0.dll
  * libpangoft2-1.0-0.dll
  * libgio-2.0-0.dll
  * libgthread-2.0-0.dll
  * libpangowin32-1.0-0.dll
  * libxml2.dll

and add more if you need them.

=== Client Images ===
The windows package is distributed with the client image files already included, for the unix clients, this is a separate package.
download the latest crossfire-client-images-x.y.z.tar.gz file from sourceforge, and untar into gtk-v2/src, this will ensure that they are included in the package.

=== Making the package ===
Finally....

Install nsis, on a debian-like system the package is called nsis

go to gtk-v2/src and run makensis gtkclient.nsi

You should have an installer file crossfire-client-windows.exe

This can now be installed on a windows system.




IP-Address  : 81.141.58.188
Old Revision: none
New Revision: http://wiki.metalforge.net/doku.php/user:cavesomething:crosscompiling_for_windows

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list