Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sdl2-image sdl2-image
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • haskell
  • sdl2-imagesdl2-image
  • Issues
  • #1

Closed
Open
Created Jan 16, 2024 by Paul Schnapp@paul_schnapp

Trouble building v2.1.0.0 on Windows 10

I'm having trouble building v2.1.0.0 on Windows 10 -- whether using the released tag or master I have the same issues.

A straight build yields errors to do with SDL_main:

error: In file included from C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL.h:32,
                 from C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL_image.h:32,
                 from Image.hsc:76:
C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL_main.h:134:17: error: conflicting types for 'SDL_main'
  134 | #define main    SDL_main
      |                 ^~~~~~~~
E:\Development\Projects\sdl2-image\Image.hsc:78:5: note: in expansion of macro 'main'
In file included from C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL.h:32,
                 from C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL_image.h:32,
                 from Image.hsc:76:
C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/msys2-20210604/mingw64/include/SDL2/SDL_main.h:146:29: note: previous declaration of 'SDL_main' was here
  146 | extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
      |                             ^~~~~~~~

From what I can tell these issues have been fixed in the past; I did some digging and found that a fix had been added to a previous sdl2-image.cabal which I copied into the current src/SDL/Raw/Image.hsc before the #include:

#define _SDL_main_h
#define SDL_main_h_
#define SDL_MAIN_HANDLED

(Having these values in the Cabal file no-longer seems to work.)

This compiles, but then fails with the linking stage for the examples executable:

Linking .stack-work\dist\cc04d683\build\sdl2-image-example\sdl2-image-example.exe ...
C://Users//paul//AppData//Local//Programs//stack//x86_64-windows//ghc-9.0.1//mingw//bin/ld.exe: C:\Users\paul\AppData\Local\Temp\ghc5056_0\ghc_4.o:ghc_3.c:(.text+0x0): multiple definition of `main'; C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/ghc-9.0.1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:17: first defined here
C://Users//paul//AppData//Local//Programs//stack//x86_64-windows//ghc-9.0.1//mingw//bin/ld.exe: C:\Users\paul\AppData\Local\Programs\stack\x86_64-windows\ghc-9.0.1\lib\x86_64-windows-ghc-9.0.1\rts-1.0/libHSrts-1.0_thr.a(RtsStartup.thr_o): in function `x86_init_fpu':

C:\GitLabRunner\builds\ux46CNax\0\ghc\ghc\rts\RtsStartup.c:96:0: error:
     multiple definition of `_fpreset'; C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/ghc-9.0.1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-CRT_fp10.o):D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/CRT_fp10.c:19: first defined here
C://Users//paul//AppData//Local//Programs//stack//x86_64-windows//ghc-9.0.1//mingw//bin/ld.exe: C:\Users\paul\AppData\Local\Programs\stack\x86_64-windows\ghc-9.0.1\lib\x86_64-windows-ghc-9.0.1\rts-1.0/libHSrts-1.0_thr.a(RtsStartup.thr_o): in function `x86_init_fpu':

C:\GitLabRunner\builds\ux46CNax\0\ghc\ghc\rts\RtsStartup.c:96:0: error:
     multiple definition of `fpreset'; C:/Users/paul/AppData/Local/Programs/stack/x86_64-windows/ghc-9.0.1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-CRT_fp10.o):D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/CRT_fp10.c:19: first defined here
C://Users//paul//AppData//Local//Programs//stack//x86_64-windows//ghc-9.0.1//mingw//bin/ld.exe: C:\Users\paul\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib/libSDL2main.a(SDL_windows_main.c.obj):(.text+0x152): undefined reference to `SDL_main'
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

If I comment out the examples exe section of the package.yaml then everything builds, but I can't use it in my project without referencing the directory directly in my stack.yaml, which I'd rather not do.

My compilation setup is using mingw via the Git for Windows bash terminal; I've tried with a couple different msys2 versions of the SDL2_image library to no avail. (Btw, if you use the same setup and run into issues compiling SDL2, you'll want to switch to version 2.24.1-1 in msys2 as newer versions fail to compile.)

EDIT: I'm using v2.8.2-2 of mingw-w64-x86_64-SDL2_image for the library.

(Everything works fine on MacOS, so this appears to be just a Windows issue.)

Any help you could provide would be very-much appreciated,

Thank you!

Edited Jan 20, 2024 by Paul Schnapp
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking