[Windows 10] Build error: conflicting types for SDL_main
Ashe opened this issue · 3 comments
As the title says, trying to do stack install sdl2-image
.
λ stack build
sdl2-image-2.0.0: configure
sdl2-image-2.0.0: build
Progress 1/18
-- While building custom Setup.hs for package sdl2-image-2.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe --builddir=.stack-work\dist\7d103d30 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\Ashley\Desktop\haskell-sdl2-examples-master\.stack-work\logs\sdl2-image-2.0.0.log
Configuring sdl2-image-2.0.0...
Preprocessing library for sdl2-image-2.0.0..
In file included from C:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL.h:32:0,
from C:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL_image.h:27,
from Image.hsc:71:
C:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL_main.h:111:17: error: conflicting types for 'SDL_main'
#define main SDL_main
^
C:\Users\Ashley\AppData\Local\Temp\stack11840\sdl2-image-2.0.0\Image.hsc:73:5: note: in expansion of macro 'main'
C:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL_main.h:117:39: note: previous declaration of 'SDL_main' was here
extern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
^~~~~~~~
compiling .stack-work\dist\7d103d30\build\SDL\Raw\Image_hsc_make.c failed (exit code 1)
command was: C:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib/../mingw/bin\gcc.exe -c .stack-work\dist\7d103d30\build\SDL\Raw\Image_hsc_make.c -o .stack-work\dist\7d103d30\build\SDL\Raw\Image_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=804 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2 -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2 -Dmain=SDL_main -I.stack-work\dist\7d103d30\build\autogen -I.stack-work\dist\7d103d30\build\global-autogen -include .stack-work\dist\7d103d30\build\autogen\cabal_macros.h -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:/Users/Ashley/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2 -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\cf99d8ac\lib\x86_64-windows-ghc-8.4.3\vector-0.12.0.1-1fezwShzdEfG3Hp1Pmvjkq\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\cf99d8ac\lib\x86_64-windows-ghc-8.4.3\primitive-0.6.4.0-39Pwmm1zkQX6bM7xFUT3Jc\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib\time-1.8.0.2\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib\Win32-2.6.1.0\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib\bytestring-0.10.8.2\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib\base-4.11.1.0\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib\integer-gmp-1.0.2.0\include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib/include -IC:\Users\Ashley\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3/lib/include/
I uninstalled Stack from my Windows machine to try and build this using this guide. I also installed sdl2-image with:
λ stack exec -- pacman --noconfirm -S mingw-w64-x86_64-SDL2_gfx mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_ttf
I don't know how often people are using SDL2-image, or if they're just using it on something other than Windows, but without smooth compilations on Windows people aren't going to take gamedev with Haskell seriously, so let me know if there's any data you need me to gather as I've read you don't have access to a Windows machine yourself. I really want this to work as I can't really work on my Haskell game too much until I know there's a way of building it on Windows.
Thanks!
@Crysikrend Can you try replacing
cpp-options: -DSDL_main_h_
with
cpp-options: -D_SDL_main_h -DSDL_main_h_
in the sdl2-image.cabal file and rebuild?
We ran into the same problem with SDL2 and SDL2-ttf before [1] [2]. It might just be a matter of doing the same changes for SDL2-image. Feel free to open a pull request if you're successful.
[1] haskell-game/sdl2@bc30282
[2] haskell-game/sdl2-ttf@fe15ad1
Also, passing the ball to @sbidin, this is very much so related to #6 (comment) about the name change for that constant and it would be nice to update Hackage/Stackage after, so that people no longer run into this.
Cheers (:
It builds! But I'll post some warnings that this produces here so that someone can make sense of them (I'm still just a beginner with all this so excuse me).
λ stack build
sdl2-image-2.0.0: configure (lib)
Configuring sdl2-image-2.0.0...
sdl2-image-2.0.0: build (lib)
Preprocessing library for sdl2-image-2.0.0..
Building library for sdl2-image-2.0.0..
[1 of 3] Compiling SDL.Raw.Helper ( src\SDL\Raw\Helper.hs, .stack-work\dist\7d103d30\build\SDL\Raw\Helper.o )
[2 of 3] Compiling SDL.Raw.Image ( .stack-work\dist\7d103d30\build\SDL\Raw\Image.hs, .stack-work\dist\7d103d30\build\SDL\Raw\Image.o )
src\SDL\Raw\Image.hsc:85:1: warning: [-Wmissing-pattern-synonym-signatures]
Pattern synonym with no type signature:
pattern IMG_INIT_JPG :: forall a. (Eq a, Num a) => a
|
85 | pattern IMG_INIT_JPG = #{const IMG_INIT_JPG}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
src\SDL\Raw\Image.hsc:86:1: warning: [-Wmissing-pattern-synonym-signatures]
Pattern synonym with no type signature:
pattern IMG_INIT_PNG :: forall a. (Eq a, Num a) => a
|
86 | pattern IMG_INIT_PNG = #{const IMG_INIT_PNG}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
src\SDL\Raw\Image.hsc:87:1: warning: [-Wmissing-pattern-synonym-signatures]
Pattern synonym with no type signature:
pattern IMG_INIT_TIF :: forall a. (Eq a, Num a) => a
|
87 | pattern IMG_INIT_TIF = #{const IMG_INIT_TIF}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
src\SDL\Raw\Image.hsc:88:1: warning: [-Wmissing-pattern-synonym-signatures]
Pattern synonym with no type signature:
pattern IMG_INIT_WEBP :: forall a. (Eq a, Num a) => a
|
88 | pattern IMG_INIT_WEBP = #{const IMG_INIT_WEBP}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
[3 of 3] Compiling SDL.Image ( src\SDL\Image.hs, .stack-work\dist\7d103d30\build\SDL\Image.o )
ignoring (possibly broken) abi-depends field for packages
sdl2-image-2.0.0: copy/register
Ashley, Alex, thanks for the fix! As for the warnings, they can be hidden the same way as in haskell-game/sdl2-ttf#7 and I don't believe they're a serious issue.
Please reopen if not the case.