Pulling my hair out...(Cross compile for windows, on Linux)


I should mention now, I have no game as of yet, I’m still trying to get my makefile to work…

I am currently working on 64-bit Ubuntu 11.10, and I am hoping to compile my (future) game for Linux and Windows (both 32-bit). So I have a few questions:

  1. Which package from the repositories should I install? mingw32 or mingw-w64?
  2. From the SDL-devel tar file (for mingw32), which files do I need to copy (not install), and to where, in order to compile using mingw?
  3. Which extra flags must I specify for mingw (like -mwindows) and how? e.g. i586-mingw32msvc-g++ -o game.o -c game.cpp {SLD CLFAGS} {WINDOWS} etc or whichever order
  4. How do I set up the game’s directory structure so that I can distribute the SDL Library (the .dll or .so files)? e.g. /game/bin/, /game/lib/, or /game/, /game/lib/

Also, regarding resources for my game, how do I make the program take resources from the directory the executable is in, not the directory it is called from? Would I always require an installer? Or is there a way I can create a bat/bash script to launch it?

P.S. Apologies if any of these questions have been answered elsewhere, but nothing seems to make sense.

Okay, After much experimenting and some more digging I can answer most of my own questions so:

  1. From the repository I installed the gcc-mingw32 package, which should also install the mingw32-binutils, and mingw32-runtime packages.

  2. From the mingw tar file (This one) I extracted the include, lib and bin directories into /usr/i586-mingw32msvc/, I also needed to get the SDL_image headers and libraries from ( from here) where i copied the files from lib to /usr/i586-mingw32msvc/lib, and the files from include to /usr/i586-mingw32msvc/include/SDL

  3. I am using the following set of flags: CXXFLAGS = -g -Wall -D_GNU_SOURCE=1 -Dmain=SDL_main
    LDFLAGS = -lmingw32 -lSDL_image -lSDLmain -lSDL -mwindows -lm -I/usr/i586-mingw32msvc/include -L/usr/i586-mingw32msvc/lib and I am compiling using i586-mingw32msvc-g++ $(CXXFLAGS) $(LDFLAGS) -c main.cpp -o main.o and linking with i586-mingw32msvc-g++ $(CXXFLAGS) main.o $(LDFLAGS) -o game.exe

  4. I am putting the supplied SDL.dll (in the bin folder from the aforementioned mingw tar file) in the same directory as the .exe when distributing.
    NOTE: I still do not know how to do this for the .so files, Is it the same method? Or should I include a disclaimer saying SDL is necessary?

I still don’t know how to solve the relative directory issue for resources, or the best way to organise the game directory.

Also, could someone sticky this as I have a feeling these are quite common problems for new game developers.