Compiling The Powder Toy 36.0 With MinGW 5.1.6

  • kaaie
    17th Jul 2010 Member 0 Permalink
    Hi, I've recently been trying to compile The Powder Toy on windows and I am coming across some issues.

    First of all I have procured MinGW 5.1.6 [Full] along with bzip2-1.0.5-2 and SDL-1.2.14.

    Using windows shell I run this command in the sources directory:

    >mingw32-make

    From this I get:

    gcc -DINTERNAL -opowder -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -fgnu89-inline
    -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -lSDL -lm -lbz2 -m
    arch=k8 -DX86 -DX86_SSE3 -msse3 powder.c http.c md5.c update.c -DLIN64
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    mingw32-make: *** [powder] Error 1

    To try and fix this problem I go into the makefile and edit lines 4 and 5 to look like this:

    CFLAGS := -Wall -std=c99 -D_POSIX_C_SOURCE=200112L
    OFLAGS := -O3 -ffast-math -funsafe-math-optimizations

    I then reenter the mingw32-make in the shell and get this:

    gcc -DINTERNAL -opowder -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -O3 -ffast-math
    -funsafe-math-optimizations -lSDL -lm -lbz2 -march=k8 -DX86 -DX86_SSE3 -msse3
    powder.c http.c md5.c update.c -DLIN64
    In file included from powder.c:77:
    hmap.h:20:7712: warning: no newline at end of file
    In file included from powder.c:2570:
    icon.h:22:20523: warning: no newline at end of file
    In file included from powder.c:3630:
    font.h:27:4: warning: no newline at end of file
    powder.c: In function `draw_svf_ui':
    powder.c:4801: warning: unused variable `c2'
    powder.c: In function `cpu_check':
    powder.c:7052: error: syntax error before "mov"
    powder.c:7055: error: syntax error before "mov"
    powder.c:7051: warning: unused variable `af'
    powder.c: In function `SDL_main':
    powder.c:7575: warning: comparison is always true due to limited range of data t
    ype
    powder.c: At top level:
    icon.h:21: warning: 'app_icon' defined but not used
    icon.h:22: warning: 'app_icon_w32' defined but not used
    http.c:41:24: sys/socket.h: No such file or directory
    http.c:42:19: netdb.h: No such file or directory
    http.c: In function `resolve':
    http.c:130: error: storage size of 'hnt' isn't known
    http.c:132: error: invalid application of `sizeof' to incomplete type `sockaddr_
    in'
    http.c:136: error: `AF_INET' undeclared (first use in this function)
    http.c:136: error: (Each undeclared identifier is reported only once
    http.c:136: error: for each function it appears in.)
    http.c:137: error: `SOCK_STREAM' undeclared (first use in this function)
    http.c:138: warning: implicit declaration of function `getaddrinfo'
    http.c:141: error: dereferencing pointer to incomplete type
    http.c:142: warning: implicit declaration of function `freeaddrinfo'
    http.c:145: error: dereferencing pointer to incomplete type
    http.c:145: error: dereferencing pointer to incomplete type
    http.c:130: warning: unused variable `hnt'
    http.c: In function `http_init':
    http.c:160: error: `SIGPIPE' undeclared (first use in this function)
    http.c: At top level:
    http.c:202: error: field `addr' has incomplete type
    http.c: In function `http_async_req_status':
    http.c:393: warning: implicit declaration of function `socket'
    http.c:393: error: `AF_INET' undeclared (first use in this function)
    http.c:393: error: `SOCK_STREAM' undeclared (first use in this function)
    http.c:402: warning: implicit declaration of function `fcntl'
    http.c:402: error: `F_GETFL' undeclared (first use in this function)
    http.c:405: error: `F_SETFL' undeclared (first use in this function)
    http.c:405: error: `O_NONBLOCK' undeclared (first use in this function)
    http.c:409: warning: implicit declaration of function `connect'
    http.c:419: error: `EINPROGRESS' undeclared (first use in this function)
    http.c:423: error: `EALREADY' undeclared (first use in this function)
    http.c:479: warning: implicit declaration of function `send'
    http.c:496: warning: implicit declaration of function `recv'
    http.c: At top level:
    http.c:70: error: storage size of `http_proxy' isn't known
    update.c: In function `exe_name':
    update.c:63: warning: implicit declaration of function `readlink'
    mingw32-make: *** [powder] Error 1

    Any help?

    Thanks,
    --kaaie
  • Andrewrox
    17th Jul 2010 Member 0 Permalink
    What are you exactly trying to do?
  • Simon
    17th Jul 2010 Administrator 0 Permalink
    While you're using MinGW, you're trying to make the linux target. you need to do "mingw32-make powder.exe"
    The Windows code is written for VC++, it might not actually compile for GCC.
  • kaaie
    17th Jul 2010 Member 0 Permalink
    Simon:
    The Windows code is written for VC++, it might not actually compile for GCC.

    Yeah I kind of thought so... But it should compile in MinGW... If it truly cannot compile how do you go about compiling the linux version?

    Also if I took the source for the older versions do you think it would compile with better results?
  • Rik
    17th Jul 2010 Member 0 Permalink
    Older versions should compile fine, the reason the Win32 version won't compile in MinGW is the x86_cpuid function, which is written for VC++ for WIN32 builds
    changing the Win32 one to match the other copy should fix the issue.
  • kaaie
    17th Jul 2010 Member 0 Permalink
    I tried compiling TPT 25.10 and got the same result... Am I using an incorrect version of SDL or something?

    Also I tried "mingw32-make powder.exe" and that did not work at all.
  • Rik
    17th Jul 2010 Member 0 Permalink
    kaaie
    The older versions I was referring to are the ones without version numbers, but with dates like so: http://powder.hardwired.org.uk/Download/older/powder-030610-0258-sse3.zip
  • kaaie
    17th Jul 2010 Member 0 Permalink
    Rik:
    The older versions I was referring to are the ones without version numbers, but with dates like so:

    Tryed with "powder-050610-1902-src" and got the same results as the first post... Has anyone had any luck in compiling the source with MinGW?
  • Simon
    17th Jul 2010 Administrator 0 Permalink
    kaaie
    050610-1902 Should compile fine, what make-file are you using, and what errors do you get?
  • kaaie
    17th Jul 2010 Member 0 Permalink
    Here is what I did:

    [Directory Path]>mingw32-make
    gcc -m32 -DINTERNAL -opowder -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -fgnu89-in
    line -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -lSDL -lm -lbz
    2 -march=k8 -DX86 -DX86_SSE3 -msse3 powder.c http.c md5.c update.c -DLIN64
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    cc1.exe: error: unrecognized command line option "-fgnu89-inline"
    cc1.exe: error: unrecognized command line option "-ftree-vectorize"
    mingw32-make: *** [powder] Error 1

    Makefile:

    SOURCES := powder.c http.c md5.c update.c
    HEADERS := font.h http.h md5.h icon.h update.h fbi.h

    CFLAGS := -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -fgnu89-inline
    OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
    LFLAGS := -lSDL -lm -lbz2
    LFLAGS_MT := -lpthreadGC2
    MFLAGS_MT := -march=k8 -DX86 -DX86_SSE3 -DMT -msse3
    MFLAGS_SSE3 := -march=k8 -DX86 -DX86_SSE3 -msse3
    MFLAGS_SSE2 := -march=k8 -DX86 -DX86_SSE2
    MFLAGS_SSE := -march=pentium3 -DX86 -DX86_SSE

    LINUX_TARG := powder-64-sse2 powder-sse powder-sse2
    WIN32_TARG := powder-sse.exe powder-sse2.exe

    powder: $(SOURCES) $(HEADERS)
    gcc -m32 -DINTERNAL -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64

    powder-sse3: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN32
    strip $@
    powder-mt: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN32
    strip $@
    powder-sse2: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN32
    strip $@
    powder-sse: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE) $(SOURCES) -DLIN32
    strip $@

    powder-64-sse3: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
    strip $@
    powder-64-sse2: $(SOURCES) $(HEADERS)
    gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN64
    strip $@

    powder-res.o: powder-res.rc powder.ico
    i586-mingw32msvc-windres powder-res.rc powder-res.o

    powder-sse3.exe: $(SOURCES) $(HEADERS) powder-res.o
    i486-mingw32-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
    strip $@
    chmod 0644 $@
    powder-mt.exe: $(SOURCES) $(HEADERS) powder-res.o
    i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_MT) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) $(LFLAGS_MT) -mwindows -DWIN32
    strip $@
    chmod 0644 $@
    powder-sse2.exe: $(SOURCES) $(HEADERS) powder-res.o
    i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
    strip $@
    chmod 0644 $@
    powder-sse.exe: $(SOURCES) $(HEADERS) powder-res.o
    i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
    strip $@
    chmod 0644 $@

    powder-src.tar.bz2: *.c *.h *.rc *.ico Makefile
    mkdir powder-src
    cp *.c *.h *.rc *.ico Makefile powder-src/
    tar cfj powder-src.tar.bz2 powder-src
    rm -rf powder-src

    release: $(LINUX_TARG) $(WIN32_TARG) powder-src.tar.bz2
    tar cfz powder-linux.tar.gz $(LINUX_TARG)
    cp /usr/i586-mingw32msvc/bin/SDL.dll .
    zip powder-win32.zip $(WIN32_TARG) SDL.dll
    mkdir -p release
    mv powder-linux.tar.gz release/
    mv powder-win32.zip release/
    mv powder-src.tar.bz2 release/
    cp powder-sse.exe powder.exe
    rm -f release/powder.zip
    zip release/powder.zip powder.exe SDL.dll
    cp powder-64-sse2 release/powder64
    rm -f release/powder64.gz
    gzip release/powder64
    rm -f release/powder.gz
    cp powder-sse release/powder
    gzip release/powder
    cd release; tar czf powder-bin.tar.gz powder.gz powder64.gz powder-linux.tar.gz powder-win32.zip powder.zip; cd ..
    rm -f $(LINUX_TARG) $(WIN32_TARG) SDL.dll powder.exe