How to: Compile with MinGW

  • JoJoBond
    1st Nov 2010 Member 0 Permalink
    This Tutorial will show you how to compile the latest Powder Toy alpha with MinGW (gcc for Windows)


    Installing MinGW

    1. Create the folder c:\MinGW
    2. Add C:\MinGW\bin; to the PATH environment variable
    a. Open System control panel
    b. Go to the Advanced tab
    c. Click the Environment Variables button
    d. Search for Path in the 2nd listbox
    e. Click Edit
    f. Add 'C:\MinGW\bin;' (without quotation marks) right at the beginning
    3. Download mingw-get (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ mingw-get-0.1-alpha-4/mingw-get-0.1-mingw32-alpha-4-bin.zip/download)
    4. Extract mingw-get and put the bin, libexec and var folders into the MinGW folder
    5. Open the Command Prompt.
    6. Type 'mingw-get install gcc' (This will install gcc)

    Installing Libraries

    7. Download SDL (http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz)
    8. Extract SDL and put the bin, include, lib and share folder into the MinGW folder
    9. Download bzip2 (http://gnuwin32.sourceforge.net/downlinks/bzip2-lib-zip.php)
    10. Extract bzip2 and put the incude and lib folders into the MinGW folder

    Prepare Source

    11. Download the Powder Toy source and extract it
    12. Edit the *.h files in the folder includes
    a. Replace all '#ifdef WIN32' lines with '#if defined(_WIN32) && !defined(__GNUC__)'
    13. Edit the *.c files in the folder src (*)
    a. Find the lines which start with '_inline '
    b. Replace the '#ifdef WIN32' above it with '#if defined(_WIN32) && !defined(__GNUC__)'
    c. In powder.c search for 'max(' and replace the '#ifdef WIN32' above it with '#if defined(_WIN32) && !defined(__GNUC__)'

    Compile and get dlls

    14. Since you can not use the make file I made small .bat file to compile everything, download it (http://www.filefactory.com/file/b416fh3/n/compile.zip)
    15. Extract the file and put the compile.bat into the folder of the Powder Toy source (where the src and includes folders are)
    16. Run compile.bat and go thru the dialogs. (This will compile the source)
    17. Copy the sdl.dll from 'C:\mingw\bin' to the place of your Powder Toy executable
    18. Download the bzip2 binaries (http://gnuwin32.sourceforge.net/downlinks/bzip2-bin-zip.php)
    19. Extract the bzip2 binaries and copy the bzip2.dll from the bin folder to the place of your Powder Toy executable
    20. Powder Toy should be ready to go now.

    * NOTE: I might have forgotten some changes I did to the source files so please post if have trouble with the how-to.
  • Maniachacker
    2nd Nov 2010 Member 0 Permalink
    WIKI!!!!!!!!!!! If no one else will i can do it, might not check this thread for a while but...
  • JoJoBond
    2nd Nov 2010 Member 0 Permalink
    I already talked with Simon about making the code more compatible, so that the preparation isn't necessary any more. As soon as we come to a conclusion I can add it into the Wiki. In the meantime you can of course add this yourself. It might only get easier in the future.
  • Simon
    2nd Nov 2010 Administrator 0 Permalink
    Just a quick reply to your e-mail: While I don't have the time at the moment to test this, I would suggest using "!defined(__GNUC__)" instead of "defined(_MSC_VER)" (This is already in use in other areas of the code, so I know it works)
  • JoJoBond
    2nd Nov 2010 Member 0 Permalink
    Thanks for pointing this out Simon I'll add this to my post.
  • pilojo
    2nd Nov 2010 Member 0 Permalink
    JoJoBond:
    Go to the Advanced tab

    I'm on vista and that does not exist. Will this compile for linux too?
  • JoJoBond
    2nd Nov 2010 Member 0 Permalink
    pilojo
    It will only create windows binaries.
    For vista have a look here: http://banagale.com/changing-your-system-path-in-windows-vista.htm
  • pilojo
    2nd Nov 2010 Member 0 Permalink
    JoJoBond
    Ugh. Then I don't need it.
  • yew101
    2nd Nov 2010 Member 0 Permalink
    Maniachacker
    WTF calm down
    are you ****ing obsessed with the wiki, its like your favourite things in the world
  • jakester12345
    2nd Nov 2010 Member 0 Permalink
    When i go to install gcc i type: mingw-get install gcc and it says that it's not an internal or external command, operable program or batch file.

    Please Help

    Cheers, Jakester12345