ocaml / graphics

The Graphics library from OCaml, in a standalone repository
Other
56 stars 29 forks source link

Compilation on native Windows fails #27

Closed GauBen closed 3 years ago

GauBen commented 3 years ago

Logs

Steps to reproduce and logs : https://github.com/GauBen/bcotp/runs/1599361734?check_suite_focus=true#step:5:68

# C:/cygwin/home/runneradmin/.opam/ocaml-variants.4.11.1+mingw64c/lib/ocaml/caml/mlvalues.h:265:24: warning: passing argument 1 of 'gr_font' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
#   265 | #define String_val(x) ((const char *) Bp_val(x))
#       |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
# src/win32/draw.c:340:17: note: in expansion of macro 'String_val'
# src/win32/draw.c:325:27: note: expected 'char *' but argument is of type 'const char *'
#   ocamlmklib src/dllgraphics_stubs.dll,src/libgraphics_stubs.a (exit 2)
# (cd _build/default && C:\cygwin\home\runneradmin\.opam\ocaml-variants.4.11.1+mingw64c\bin\ocamlmklib.opt.exe -g -o src/graphics_stubs src/draw.o src/events.o src/open.o -lkernel32 -lgdi32 -luser32)
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x5c): multiple definition of `grremember_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x60): first defined here
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x60): multiple definition of `grdisplay_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x64): first defined here
# collect2: error: ld returned 1 exit status
# ** Fatal error: Error during linking

Or:

Solution

I found a way to compile graphics on Cygwin:

Regards, Gautier

dra27 commented 3 years ago

This is actually the mingw64 version that you're using, not Cygwin (Cygwin's just the shell). This and #20 should fix the problems!

GauBen commented 3 years ago

I tried your branch and it's still broken: https://github.com/GauBen/bcotp/runs/1601747546?check_suite_focus=true#step:5:59

dra27 commented 3 years ago

Oh, it’s gcc 10 - I think my Cygwin’s still running 9. I’ll update and push a fix for that shortly.

Thanks for testing it so quickly!

GauBen commented 3 years ago

It worked! https://github.com/GauBen/bcotp/runs/1602336678#step:5:1

Feel free to try the terrible game I cross-compiled thanks to your commits :tada:

dra27 commented 3 years ago

Fix merged - I'll do a 5.1.1 release in the new year