Compiling on Windows, using Main-SDL.c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soluzar
    Rookie
    • Jan 2010
    • 6

    Compiling on Windows, using Main-SDL.c

    In my opinion, the SDL display module is by far the most pleasant to use. I'm not convinced that this opinion is widely shared, but in any case I recently compiled it from source, for Windows. There's not a lot of information 'out there' on this topic and what does exist is a little incomplete.

    I'm hoping to do something about that. I'd like to document exactly what I did to get it working. Step by step instructions, so that anyone else can compile this a little more easily than I did. I made a few missteps along the way before eventual success, so these instructions may not be precisely correct at first.

    With your help I would like to make them correct, and keep them up-to-date. If you can, and are willing, please attempt to follow these instructions and let me know where you run into trouble. Even if you've got no interest in the Windows/SDL version of Angband, it would help your fellow players.

    The Procedure:

    1) Install the compilation tools.

    I'm using Orwell Dev-C++ which is a fork and a continuation of the older Bloodshed Dev-C++ which now appears to have stagnated. It's a handy IDE that works with the MinGW32 compiler.



    That's the latest 32-bit version. It will work fine if you're running 64-bit Windows, I know I am.

    2) Download the libraries.

    Under the Tools menu in Dev-C++ there is an option to "Check For Updates/Packages" - in spite of the somewhat unhelpful name this will allow you to download additional libraries. If you click it you need to choose a site from which to download. PlanetMirror.com wasn't working when I tried, so pick devpaks.org and choose the following:

    SDL 1.2.15
    SDLimage 1.2.12
    SDLttf 2.0.11
    Zlib 1.2.3
    LibPNG 1.2.8

    Those are the exact versions I chose. At time of writing I believe the SDL packages to be the newest ones available for Dev-C++ although there may be newer upstream releases. Do not choose a newer LibPNG - it will not work.

    3) Create a new project

    Select 'Empty Project' and be sure to move the radio button to "C Project and not "C++ Project". Add all the .c source code files from /src as well as from src/object, src/monster and src/player subfolders. Add the .c files from /src/win/ as well as the angband.rc file.

    If you want to, you can create 'project folders' to match the source code folders. There's no point to it, but I did anyway. Because it's slightly neater, and pleases my mild OCD.

    4) Set the project options

    Open the project options (right-click the project name) and we can set the options required to compile this. First things first, if you want to there's the option to set the icon for your executable, using the angband.ico file included in the source tarball.

    Click to the Parameters tab. The compiler parameters should be "-lmingw32 -mwindows -DWINDOWS -DUSE_SDL" while the linker parameters should be "-lwinmm -lmingw32 -mwindows -lSDLmain -lSDL -lSDL_ttf -lpng -lSDL_image".

    Click to the Directories tab next. I'm pretty sure these options ought to be defaults but they weren't so... I'm setting them. If you understand better than I, then please explain it to me.

    Under the Library Directories subtab, you need "C:\Program Files (x86)\Dev-Cpp\lib" while under the Include Directories subtab you need "C:\Program Files (x86)\Dev-Cpp\include\SDL". If you put your Dev-C++ installation in another place than "C:\Program Files (x86)\Dev-Cpp\" then you will need to adjust those paths in a predictable way.

    That much is required for finding the SDL libraries you put in, but it also needs: "C:\Games\angband-v3.3.2\src\" "C:\Games\angband-v3.3.2\src\win\include" to finish the job.

    With all that done, and assuming no mistakes were made, you should be able to compile a working version of Angband SDL for Windows.
  • Magnate
    Angband Devteam member
    • May 2007
    • 5110

    #2
    Thanks for that - I'm sure it will come in very handy. I haven't tested it yet, but will report back when I do.
    "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

    Comment

    • PowerWyrm
      Prophet
      • Apr 2008
      • 2987

      #3
      For my variant, I have a whole procedure to compile the SDL client under Windows. The basic steps are:
      - get Free Command Line Tools (free BCC compiler from Borland)
      - get ZLIB 1.2.7 and LIBPNG 1.5.11 source code, compile them using given makefiles, generate static lib files
      - get SDL 1.2.15, FreeType 2.4.10, SDL_ttf 2.0.11, SDL_image 1.2.12, MAD 0.15.1b (for the new MP3 support), SDL_mixer 1.2.12 source code, fix some of the files for compile errors, compile them with makefiles I wrote, generate static lib files
      - copy headers and lib files into accessible directories and compile the SDL client using a dedicated makefile
      - enjoy a nice SDL client
      PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎