Skip to content

GHC 8.0.2 on Windows "error: conflicting types for 'SDL_main'" workaround #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nxths opened this issue Feb 13, 2017 · 36 comments · Fixed by #174
Closed

GHC 8.0.2 on Windows "error: conflicting types for 'SDL_main'" workaround #139

nxths opened this issue Feb 13, 2017 · 36 comments · Fixed by #174

Comments

@nxths
Copy link
Contributor

nxths commented Feb 13, 2017

cpp-options: -D_SDL_main_h needs to be added to the .cabal file to compile on Windows with GHC 8.0.2 (credits to <RyanGlScott> in #ghc http://ircbrowse.net/day/ghc/2017/01/28)

It looks like this is technically a problem with the hsc2hs implementation (see above irc discussion) so this isn't necessarily an issue with sdl2 itself, but if this cpp flag doesn't cause any other issues I can make a patch for it

@codeweaverx
Copy link

Fantastic. I just ran into this problem this weekend, and I'm really glad to see that someone found a workaround. Testing it now.

@LukaHorvat
Copy link

Any progress on this?

@ocharles
Copy link
Member

@codeweaverx Did your testing show this was what you needed?

@Lokathor
Copy link
Contributor

Tested just now on Windows 7, stack 1.4, lts-8.12 (GHC 8.0.2): Successful build of the lib and the examples with the cpp-options flag given above. Stick it behind an if os(Win32) or whatever the cabal file syntax is and you should be good.

@Mikolaj
Copy link
Contributor

Mikolaj commented May 27, 2017

yep, the workaround also works on appveyor: http://ci.appveyor.com/project/Mikolaj/lambdahack/build/1.0.12

@RyanGlScott
Copy link

This was fixed in #142, right?

@ocharles
Copy link
Member

Looks like it, can always re-open if we got that wrong!

@Mikolaj
Copy link
Contributor

Mikolaj commented Jun 13, 2017

BTW, if nobody reopens in a few days, could we release a new version on Hackage? Then I could simplify appveyor's and users' instructions for compiling my project. Thanks!

@ocharles
Copy link
Member

That sounds perfectly reasonable to me.

@Mikolaj
Copy link
Contributor

Mikolaj commented Jul 31, 2017

@haskell-game: would now be a good time for a new release? Perhaps also with a test that it works with the official GHC 8.2.1? Did anybody test that already? If not, I can volunteer.

@nickkuk
Copy link
Contributor

nickkuk commented Jul 31, 2017

@Mikolaj My application works fine with sdl2-2.2.0 and GHC 8.2.1

@Mikolaj
Copy link
Contributor

Mikolaj commented Jul 31, 2017

@nickkuk: thank you. I've just compiled on 8.2.1 with

cabal install --disable-library-profiling --disable-profiling -j1 -fno-linear -fexamples -fopengl-example

and all the examples compile and do something (not sure if they do the right thing, but nothing looks out of order, except the joystick example, which rightly complains that I have no joystick).

@ocharles
Copy link
Member

ocharles commented Jul 31, 2017 via email

@Mikolaj
Copy link
Contributor

Mikolaj commented Aug 22, 2017

@ocharles: I've finally managed to install new libsdl2-dev and libsd2-ttf-dev on the hackage docs building server. Could you restart doc building so that we can see if it works? Thanks!

@Mikolaj
Copy link
Contributor

Mikolaj commented Aug 23, 2017

Or anybody from @haskell-game: ^^^. BTW, thanks for the sdl2 release!

@Mikolaj
Copy link
Contributor

Mikolaj commented Aug 27, 2017

OK, never mind, the sdl2 packages I installed are too old, because the Ubuntu installation is too old. Too bad. :(

@Invisible-Rabbit-Hunter
Copy link

Does not work on windows 10. I still have this problem on sdl2 2.3.0.

@ocharles
Copy link
Member

ocharles commented Oct 2, 2017

@Supernerd11 can you provide any type of reproducible example and the output you get?

@Invisible-Rabbit-Hunter
Copy link

@ocharles
Doing stack install sdl2-2.3.0 yields

sdl2-2.3.0: configure
sdl2-2.3.0: build

--  While building package sdl2-2.3.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59
d0ab build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\Users\jonathan.osser\Documents\Programming\haskell\sandbox\.stack-work\logs\sdl2-2.3.0
.log

    Configuring sdl2-2.3.0...
    Building sdl2-2.3.0...
    Preprocessing library sdl2-2.3.0...
    In file included from C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/inc
lude/SDL2/SDL.h:32:0,
                     from Enum.hsc:910:
    C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2/SDL_main.h:1
04:17: error: conflicting types for 'SDL_main'
     #define main    SDL_main
                     ^
    C:\Users\jonathan.osser\AppData\Local\Temp\stack38072\sdl2-2.3.0\Enum.hsc:912:5: note: in expansion of macro 'main'
    C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2/SDL_main.h:1
10:31: note: previous declaration of 'SDL_main' was here
     extern C_LINKAGE DECLSPEC int SDL_main(int argc, char *argv[]);
                                   ^
    compiling .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c failed (exit code 1)
    command was: C:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\mingw\bin\gcc.exe -c .sta
ck-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c -o .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.o -fno-stac
k-protector -D__GLASGOW_HASKELL__=800 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=
1 -Iinclude -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:/Us
ers/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2 -Dmain=SDL_main -D_SD
L_main_h -I.stack-work\dist\ca59d0ab\build\autogen -include .stack-work\dist\ca59d0ab\build\autogen\cabal_macros.h -IC:\
Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osse
r\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Pro
grams\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\e46bddb7\lib\x86_64-windows-ghc-8.0.2\vector
-0.12.0.1-692PQMDMB6pIQ1uGwefDcQ\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-201
50512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\inclu
de -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonat
han.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\L
ocal\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack
\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msy
s2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\time-1.6
.0.1\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\U
sers\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\e46bddb
7\lib\x86_64-windows-ghc-8.0.2\primitive-0.6.2.0-4578caNkWQ54Gt1mxLF2Yh\include -IC:\Users\jonathan.osser\AppData\Local\
Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_
64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20
150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\incl
ude -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jona
than.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\
Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stac
k\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ms
ys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw6
4\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\User
s\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\Ap
pData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Program
s\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-wind
ows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\
mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC
:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.os
ser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\P
rograms\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_6
4-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2
\lib\Win32-2.3.1.1\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\bytestrin
g-0.10.8.1\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include
-IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan
.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\base-4.9.1.0\include -IC:\Users\jonathan.osser\AppData\
Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\integer-gmp-1.0.0.1\include -IC:\Users\jonathan.osser\AppData\Local\Pr
ograms\stack\x86_64-windows\ghc-8.0.2\lib/include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\
ghc-8.0.2/lib/include/

and cloning the repo and doing stack install returns

sdl2-2.3.0: build (lib)
Preprocessing library sdl2-2.3.0...
In file included from C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/includ
/SDL2/SDL.h:32:0,
                 from Enum.hsc:910:
C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2/SDL_main.h:104:
7: error: conflicting types for 'SDL_main'
 #define main    SDL_main
                 ^
C:\Users\jonathan.osser\Documents\Programming\haskell\sdl2\Enum.hsc:912:5: note: in expansion of macro 'main'
C:/Users/jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2/SDL_main.h:110:
1: note: previous declaration of 'SDL_main' was here
 extern C_LINKAGE DECLSPEC int SDL_main(int argc, char *argv[]);
                               ^
compiling .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c failed (exit code 1)
command was: C:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\mingw\bin\gcc.exe -c .stack-
ork\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c -o .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.o -fno-stack-p
otector -D__GLASGOW_HASKELL__=800 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -
include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:/Users
jonathan.osser/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/include/SDL2 -Dmain=SDL_main -D_SDL_m
in_h -I.stack-work\dist\ca59d0ab\build\autogen -include .stack-work\dist\ca59d0ab\build\autogen\cabal_macros.h -IC:\Use
s\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\A
pData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Progra
s\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\e46bddb7\lib\x86_64-windows-ghc-8.0.2\vector-0.
2.0.1-692PQMDMB6pIQ1uGwefDcQ\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-201505
2\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include
IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan
osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Loca
\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x8
_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-
0150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\time-1.6.0.
\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\User
\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\sr\snapshots\e46bddb7\l
b\x86_64-windows-ghc-8.0.2\primitive-0.6.2.0-4578caNkWQ54Gt1mxLF2Yh\include -IC:\Users\jonathan.osser\AppData\Local\Pro
rams\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-
indows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150
12\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include
-IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonatha
.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Loc
l\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x
6_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2
20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\i
clude -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\j
nathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppDa
a\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\s
ack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows
msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\min
w64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\U
ers\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser
AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Prog
ams\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-w
ndows\msys2-20150512\mingw64\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\li
\Win32-2.3.1.1\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\bytestring-0
10.8.1\include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC
\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include -IC:\Users\jonathan.os
er\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\base-4.9.1.0\include -IC:\Users\jonathan.osser\AppData\Loc
l\Programs\stack\x86_64-windows\ghc-8.0.2\lib\integer-gmp-1.0.0.1\include -IC:\Users\jonathan.osser\AppData\Local\Progr
ms\stack\x86_64-windows\ghc-8.0.2\lib/include -IC:\Users\jonathan.osser\AppData\Local\Programs\stack\x86_64-windows\ghc
8.0.2/lib/include/

--  While building package sdl2-2.3.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca5
d0ab build lib:sdl2 --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

Is this what you meant?

@ocharles
Copy link
Member

ocharles commented Oct 2, 2017

Hopefully some of the Window's-using devs can shed some light on this.

@nxths
Copy link
Contributor Author

nxths commented Oct 3, 2017

@Supernerd11 I can't reproduce this on an up to date 64-bit Windows 10 box, the following builds correctly:

PS C:\code> git clone http://github.com/haskell-game/sdl2.git
Cloning into 'sdl2'...
remote: Counting objects: 4679, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 4679 (delta 17), reused 18 (delta 8), pack-reused 4650
Receiving objects: 100% (4679/4679), 2.51 MiB | 3.72 MiB/s, done.
Resolving deltas: 100% (3390/3390), done.
Checking connectivity... done.
PS C:\code> cd sdl2
PS C:\code\sdl2> git log | head
commit 0196faa
Author: aszlig aszlig@redmoonstudios.org
Date: Wed Sep 20 06:59:26 2017 +0200

gamecontroller: Fix button pressed/release state

The SDL_PRESSED and SDL_RELEASED state doesn't seem to be very reliable
for acquiring button states, because they seem to be fire also whenever
the analog sticks are below threshold.

PS C:\code\sdl2> stack init
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:

  • sdl2.cabal

Selecting the best among 11 snapshots...

  • Matches lts-9.6

Selected resolver: lts-9.6
Initialising configuration using resolver: lts-9.6
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.
PS C:\code\sdl2> stack build
sdl2-2.3.0: configure (lib)
Configuring sdl2-2.3.0...
sdl2-2.3.0: build (lib)
Preprocessing library sdl2-2.3.0...
[ 1 of 38] Compiling SDL.Vect ( src\SDL\Vect.hs, .stack-work\dist\ca59d0ab\build\SDL\Vect.o )
[ 2 of 38] Compiling SDL.Raw.Platform ( src\SDL\Raw\Platform.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Platform.o )
[ 3 of 38] Compiling SDL.Raw.Error ( src\SDL\Raw\Error.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Error.o )
[ 4 of 38] Compiling SDL.Raw.Enum ( .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum.o )
[ 5 of 38] Compiling SDL.Raw.Power ( src\SDL\Raw\Power.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Power.o )
[ 6 of 38] Compiling SDL.Raw.Types ( .stack-work\dist\ca59d0ab\build\SDL\Raw\Types.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Types.o )
[ 7 of 38] Compiling SDL.Raw.Filesystem ( src\SDL\Raw\Filesystem.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Filesystem.o )
[ 8 of 38] Compiling SDL.Raw.Event ( src\SDL\Raw\Event.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Event.o )
[ 9 of 38] Compiling SDL.Raw.Haptic ( src\SDL\Raw\Haptic.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Haptic.o )
[10 of 38] Compiling SDL.Raw.Thread ( src\SDL\Raw\Thread.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Thread.o )
[11 of 38] Compiling SDL.Raw.Timer ( src\SDL\Raw\Timer.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Timer.o )
[12 of 38] Compiling SDL.Raw.Video ( src\SDL\Raw\Video.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Video.o )
[13 of 38] Compiling SDL.Raw.Basic ( src\SDL\Raw\Basic.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Basic.o )
[14 of 38] Compiling SDL.Raw.Audio ( src\SDL\Raw\Audio.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw\Audio.o )
[15 of 38] Compiling SDL.Raw ( src\SDL\Raw.hs, .stack-work\dist\ca59d0ab\build\SDL\Raw.o )
[16 of 38] Compiling SDL.Power ( src\SDL\Power.hs, .stack-work\dist\ca59d0ab\build\SDL\Power.o )
[17 of 38] Compiling SDL.Internal.Vect ( src\SDL\Internal\Vect.hs, .stack-work\dist\ca59d0ab\build\SDL\Internal\Vect.o )
[18 of 38] Compiling SDL.Internal.Types ( src\SDL\Internal\Types.hs, .stack-work\dist\ca59d0ab\build\SDL\Internal\Types.o )
[19 of 38] Compiling SDL.Internal.Numbered ( src\SDL\Internal\Numbered.hs, .stack-work\dist\ca59d0ab\build\SDL\Internal\Numbered.o )
[20 of 38] Compiling SDL.Input.Keyboard.Codes ( src\SDL\Input\Keyboard\Codes.hs, .stack-work\dist\ca59d0ab\build\SDL\Input\Keyboard\Codes.o )
[21 of 38] Compiling SDL.Input.Keyboard ( src\SDL\Input\Keyboard.hs, .stack-work\dist\ca59d0ab\build\SDL\Input\Keyboard.o )
[22 of 38] Compiling SDL.Input.GameController ( src\SDL\Input\GameController.hs, .stack-work\dist\ca59d0ab\build\SDL\Input\GameController.o )
[23 of 38] Compiling SDL.Exception ( src\SDL\Exception.hs, .stack-work\dist\ca59d0ab\build\SDL\Exception.o )
[24 of 38] Compiling SDL.Hint ( src\SDL\Hint.hs, .stack-work\dist\ca59d0ab\build\SDL\Hint.o )
[25 of 38] Compiling SDL.Internal.Exception ( src\SDL\Internal\Exception.hs, .stack-work\dist\ca59d0ab\build\SDL\Internal\Exception.o )
[26 of 38] Compiling SDL.Filesystem ( src\SDL\Filesystem.hs, .stack-work\dist\ca59d0ab\build\SDL\Filesystem.o )
[27 of 38] Compiling SDL.Input.Joystick ( src\SDL\Input\Joystick.hs, .stack-work\dist\ca59d0ab\build\SDL\Input\Joystick.o )
[28 of 38] Compiling SDL.Time ( src\SDL\Time.hs, .stack-work\dist\ca59d0ab\build\SDL\Time.o )
[29 of 38] Compiling SDL.Video.OpenGL ( src\SDL\Video\OpenGL.hs, .stack-work\dist\ca59d0ab\build\SDL\Video\OpenGL.o )
[30 of 38] Compiling SDL.Video.Renderer ( src\SDL\Video\Renderer.hs, .stack-work\dist\ca59d0ab\build\SDL\Video\Renderer.o )
[31 of 38] Compiling SDL.Input.Mouse ( src\SDL\Input\Mouse.hs, .stack-work\dist\ca59d0ab\build\SDL\Input\Mouse.o )
[32 of 38] Compiling SDL.Input ( src\SDL\Input.hs, .stack-work\dist\ca59d0ab\build\SDL\Input.o )
[33 of 38] Compiling SDL.Video ( src\SDL\Video.hs, .stack-work\dist\ca59d0ab\build\SDL\Video.o )
[34 of 38] Compiling SDL.Event ( src\SDL\Event.hs, .stack-work\dist\ca59d0ab\build\SDL\Event.o )
[35 of 38] Compiling SDL.Audio ( src\SDL\Audio.hs, .stack-work\dist\ca59d0ab\build\SDL\Audio.o )
[36 of 38] Compiling Data.Bitmask ( src\Data\Bitmask.hs, .stack-work\dist\ca59d0ab\build\Data\Bitmask.o )
[37 of 38] Compiling SDL.Init ( src\SDL\Init.hs, .stack-work\dist\ca59d0ab\build\SDL\Init.o )
[38 of 38] Compiling SDL ( src\SDL.hs, .stack-work\dist\ca59d0ab\build\SDL.o )
sdl2-2.3.0: copy/register
Installing library in
C:\code\sdl2.stack-work\install\7abedeba\lib\x86_64-windows-ghc-8.0.2\sdl2-2.3.0-HZn4llplV8GLpI15UhRHYc
Registering sdl2-2.3.0...
PS C:\code\sdl2>

@Invisible-Rabbit-Hunter
Copy link

How did you install SDL2? I've tried reinstalling it now, and it didn't help. I still get the same message.

@nxths
Copy link
Contributor Author

nxths commented Oct 3, 2017

@Supernerd11 I followed http://www.reddit.com/r/haskellgamedev/comments/4jpthu/windows_sdl2_is_now_almost_painless_via_stack/ originally, so it should be stack exec -- pacman -S mingw-w64-x86_64-SDL2

@Invisible-Rabbit-Hunter
Copy link

I'm gonna try to reinstall stack to ser if this continues.

@Invisible-Rabbit-Hunter
Copy link

I have reinstalled stack, and everything. It still gave the same error.

@Invisible-Rabbit-Hunter
Copy link

I managed to fix it by changing cpp-options: -D_SDL_main_h to cpp-options: -DSDL_main_h_ or cpp-options: -DSDL_main_h_ -D_SDL_main_h

@ocharles
Copy link
Member

ocharles commented Oct 4, 2017

Maybe we should add that -D too? Would it hurt to have both? @Supernerd11, which SDL2 do you have installed?

@Invisible-Rabbit-Hunter
Copy link

I think the problem is me using the wrong version of SDL2. I have 2.0.6, and they might have changed it then... Anyway, it compiles but doesn't actually run, so this didn't get me far.

@Invisible-Rabbit-Hunter
Copy link

Invisible-Rabbit-Hunter commented Oct 4, 2017

Actually, it works now... I don't know why, but it does.

@schell
Copy link
Contributor

schell commented Nov 10, 2017

This morning I ran into this problem on a fresh install of Windows 10. I've fixed it by adding -DSDL_main_h_ to the cpp-options. I'll make a pull request.

@cronokirby
Copy link

I've run into this trying to build http://github.com/jxv/dino-rush on windows 7 64 bit
Here's the output where it fails http://hastebin.com/akudokahup.http

@cronokirby
Copy link

This issue is because of the older sdl version this project depends on, right?

@ysitbon
Copy link

ysitbon commented Sep 30, 2018

As @cronokirby , I'm running into the exactly same issue when trying to build http://github.com/jxv/dino-rush repository.

  • Windows 10 N 64-bit Version 1709 Build 16299.665
  • Stack 1.7.1
λ  stack build

Warning: F:\Yoann\documents\apps\dino-rush\dino-rush.cabal was modified manually. Ignoring
         F:\Yoann\documents\apps\dino-rush\package.yaml in favor of the cabal file. If you want to
         use the package.yaml file instead of the cabal file, then please delete the cabal file.
sdl2-2.2.0: configure
sdl2-2.2.0: build
Progress 1/5

--  While building custom Setup.hs for package sdl2-2.2.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59d0ab build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: F:\Yoann\documents\apps\dino-rush\.stack-work\logs\sdl2-2.2.0.log

    Configuring sdl2-2.2.0...
    Building sdl2-2.2.0...
    Preprocessing library sdl2-2.2.0...
    In file included from C:/Users/Yoann/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL.h:32:0,
                     from Enum.hsc:910:
    C:/Users/Yoann/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\Yoann\AppData\Local\Temp\stack12980\sdl2-2.2.0\Enum.hsc:912:5: note: in expansion of macro 'main'
    C:/Users/Yoann/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\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c failed (exit code 1)
    command was: C:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\mingw\bin\gcc.exe -c .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.c -o .stack-work\dist\ca59d0ab\build\SDL\Raw\Enum_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=800 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iinclude -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:/Users/Yoann/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2 -Dmain=SDL_main -I.stack-work\dist\ca59d0ab\build\autogen -include .stack-work\dist\ca59d0ab\build\autogen\cabal_macros.h -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\sr\snapshots\518da490\lib\x86_64-windows-ghc-8.0.2\vector-0.12.0.1-692PQMDMB6pIQ1uGwefDcQ\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\time-1.6.0.1\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\sr\snapshots\518da490\lib\x86_64-windows-ghc-8.0.2\primitive-0.6.2.0-4578caNkWQ54Gt1mxLF2Yh\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\Win32-2.3.1.1\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\bytestring-0.10.8.1\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\base-4.9.1.0\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib\integer-gmp-1.0.0.1\include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\lib/include -IC:\Users\Yoann\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2/lib/include/

@ysitbon
Copy link

ysitbon commented Oct 3, 2018

@cronokirby It can't be built for ghc-8.0.2 on Windows, with any resolver related to this version. Use nightly resolver or 12.11 instead. But then sdl2-image will throw the same build error... See haskell-game/sdl2-image#9

@schell
Copy link
Contributor

schell commented Oct 3, 2018

@jxv dino rush love notification :)

@valyagolev
Copy link

whoever stumbles upon it like me: you actually want sdl2-2.3.0.1 in your extra-deps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.