-
Notifications
You must be signed in to change notification settings - Fork 87
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
SDL2 can't be built on Windows at the moment #277
Comments
UPD: logs of workflow expire fast, so you can just check the last run from here: https://github.com/haskell-game/sdl2/actions |
I have the same issue and found a workaround.
This is just the oldest version that's still available on repo.msys2.org, I didn't test any other. |
I have probably the same problem without stack, just with (an old) cabal: https://ci.appveyor.com/project/Mikolaj/lambdahack/build/job/5sab5gwkru56fpip It says
|
And the workaround did not succeed for me, because my problem (the "Missing" line above) is the same as of #277 (comment) and is different than the one from the description of the ticket. |
And the same problem (mine) shows up in the official CI of this repo as well: https://github.com/haskell-game/sdl2/actions/runs/3732668333/jobs/6332423036#step:9:21
|
I've opened a new ticket for that separate issue: #280 |
I've tried building with cabal and I've had success. Unpack it and drop files to your msys mingw64 installation folder (example: C:\msys64\mingw64). So there's this bug in cabal which can't see if pkg-config path is relative or absolute and some other issues with including files and lib folders (I'm not sure if stack has this same issue) but to workaround it, I had to go
If you want SDL_image library, then you need to also copy mingw package to msys/mingw64 and edit sdl2_image.pc file with prefix. I've spent whole week figuring this out. Hope this helps someone. |
I would like to expand a bit on @Poselsky answer:
after extracting the SDL2 archive, the files in questions, depending on your setup, may be here:
You need to copy the dirs over to mingw64 matching dirs, e.g.
Respectively, edit the
I did not have to add the path to the Otherwise it works, thanks! |
This failed for
It seems that something has been changed through this versions. But everything is Ok with
Hope this will be useful as an temporary workaround. |
It looks like you are using an older GHC version. If that's unintentional, try a more recent GHC version as well as a newer sdl2. |
This is a newer feature and provided under the |
Those who still have compilation issues, take a look at this potential workaround. After trying to get stack working instead of cabal, I broke my previous cabal environment and couldn't compile SDL anymore. Build script with these environment vars fixed environment for me: haskell/cabal#7096 This brings question, can't we supply a flag which would link against SDL2.dll? Looks like cabal itself has some linking issues and if this were to occur again after potential build bug fixes, temporary dll link seems like a good fix to me. Also novices who would love to dabble with SDL wouldn't need to learn intricacies of MINGW. |
The latest version I had success using is v2.24.1-1:
Everything after that version failed with the |
@jship @Poselsky @madjestic @Lev135 @Mikolaj @toolcreator @kapkekes |
Just here to confirm that this is still an issue; and jship's solution still works. Other stuff I did before that, that didn't work:
Edit (2024.06.14): still true as of June 2024, |
It looks like the suggestions from #277 (comment) and #277 (comment) no longer work as However, I get the same error using this version: Error with SDL2-2.24.2-12024-08-11 17:39:47.796175: [warn] sdl2 > error: ld.lld: error: undefined symbol: __stack_chk_fail
2024-08-11 17:39:47.796175: [warn] sdl2 > >>> referenced by libSDL2main.a(SDL_windows_main.c.obj):(.text)
2024-08-11 17:39:47.796675: [warn] sdl2 >
2024-08-11 17:39:47.796675: [warn] sdl2 > ld.lld: error: undefined symbol: __stack_chk_guard
2024-08-11 17:39:47.796675: [warn] sdl2 > >>> referenced by libSDL2main.a(SDL_windows_main.c.obj):(.refptr.__stack_chk_guard)
2024-08-11 17:39:47.797175: [warn] sdl2 > clang: error: linker command failed with exit code 1 (use -v to see invocation)
2024-08-11 17:39:47.797175: [warn] sdl2 > Any other ideas in terms of workarounds or have a copy of the original build? Thanks. |
I was able to figure out a workaround, it takes inspiration from @SturdyPose suggestion, however does not assume mingw64 installation on host by setting everything up via Bash. For our example, I will be using 2.30.6 variant of SDL2.
For our tutorial I will assume you unpack the zip file in your project directory but this file is going to be used globally by all projects that rely on SDL2 unless you redo the steps.
stack exec -- bash This should start an interactive shell with MingW64 (or your default MingW setup with Stack.)
cp SDL2-2.30.6/x86_64-w64-mingw32/lib/* -r /mingw64/lib/
cp SDL2-2.30.6/x86_64-w64-mingw32/include/* -r /mingw64/include/
cp SDL2-2.30.6/x86_64-w64-mingw32/bin/* -r /mingw64/bin/ Once you are done, you can safely Voila! You now should be able to build. This workaround assumes you only have one version of SDL installed at a time and injects SDL into your If you plan to change the version of SDL2, make sure to force a rebuild by removing stack exec -- ghc-pkg unregister --force sdl2 |
Problem
Can't build SDL2.
Description
I tried to build this library using Haskell Stack on Windows 11, but encountered a problem:
(full logs are here: log.txt)
As far as I can tell, this should be a problem with the SDL2 from MinGW64 repository. Sadly, I don't know how to contact its maintainers.
Steps to reproduce:
Workaround solution
idea by @toolcreator: #277 (comment)
the newest working version found by @jship: #277 (comment)
The text was updated successfully, but these errors were encountered: