opam-cross-windows
opam-cross-windows copied to clipboard
Fail to build ocaml-windows with mxe: "flexlink does not work"
Hello,
I can successfully build ocaml-windows using mingw-gcc from my distribution repo but not using MXE cross toolchain. Tested in both archlinux (in docker) and Ubuntu 22.04 and I got exact same result. Tested with both ocaml 4.14.1 and 5.1.1 and same problem.
My goal is to use MXE to build "ssl-windows" package because I can't using distribution package mingw-gcc. If you know how to build openssl without MXE, please explain to me how to do so.
I configured ocaml to use MXE as follow:
export TOOLPREF32=/mnt/mxe/usr/bin/i686-w64-mingw32.static-
export TOOLPREF64=/mnt/mxe/usr/bin/x86_64-w64-mingw32.static-
The error I get with MXE mingw-gcc is:
- When I try to build ocaml-windows32:
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved flexdll-windows.0.42 (cached)
⊘ removed flexdll-windows.0.42
∗ installed conf-gcc-windows32.1
⬇ retrieved ocaml-windows32.4.12.0 (cached)
∗ installed flexdll-windows.0.42
[ERROR] The compilation of ocaml-windows32.4.12.0 failed at "/bin/sh ./build.sh i686-w64-mingw32.static".
#=== ERROR while compiling ocaml-windows32.4.12.0 =============================#
# context 2.2.1 | linux/x86_64 | ocaml-base-compiler.5.1.1 | git+file:///mnt/opam-cross-windows
# path ~/.opam/5.1.1/.opam-switch/build/ocaml-windows32.4.12.0
# command /bin/sh ./build.sh i686-w64-mingw32.static
# exit-code 2
# env-file ~/.opam/log/ocaml-windows32-903834-19a926.env
# output-file ~/.opam/log/ocaml-windows32-903834-19a926.out
### output ###
# [...]
# /root/.opam/5.1.1/lib/flexdll-windows/flexlink -chain mingw -stack 16777216 -link -static-libgcc -exe -link "-municode" -g -o ocamlrund.exe prims.o libcamlrund.a -lws2_32 -lversion
# /root/.opam/5.1.1/lib/flexdll-windows/flexlink -chain mingw -stack 16777216 -link -static-libgcc -exe -link "-municode" -o ocamlruni.exe prims.o libcamlruni.a -lws2_32 -lversion
# make[1]: Leaving directory '/root/.opam/5.1.1/.opam-switch/build/ocaml-windows32.4.12.0/runtime'
# cp runtime/ocamlrun.exe boot/ocamlrun.exe
# make -C stdlib \
# CAMLC='$(BOOT_OCAMLC) -use-prims ../runtime/primitives' all
# make[1]: Entering directory '/root/.opam/5.1.1/.opam-switch/build/ocaml-windows32.4.12.0/stdlib'
# /root/.opam/5.1.1/bin/ocamlrun ../boot/ocamlc -use-prims ../runtime/primitives -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bin-annot -nostdlib -principal -safe-string -strict-formats -nopervasives -c camlinternalFormatBasics.mli
# the file '../boot/ocamlc' has not the right magic number: expected Caml1999X033, got Caml1999X029
# make[1]: *** [Makefile:201: camlinternalFormatBasics.cmi] Error 127
# make[1]: Leaving directory '/root/.opam/5.1.1/.opam-switch/build/ocaml-windows32.4.12.0/stdlib'
# make: *** [Makefile:143: coldstart] Error 2
- When I try to build ocaml-windows64
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved ocaml-windows64.5.1.1 (cached)
[ERROR] The compilation of ocaml-windows64.5.1.1 failed at "/bin/sh ./build.sh x86_64-w64-mingw32.static /root/.opam/5.1.1 /root/.opam/5.1.1/lib/flexdll-windows".
#=== ERROR while compiling ocaml-windows64.5.1.1 ==============================#
# context 2.2.1 | linux/x86_64 | ocaml-base-compiler.5.1.1 | git+file:///mnt/opam-cross-windows
# path ~/.opam/5.1.1/.opam-switch/build/ocaml-windows64.5.1.1
# command /bin/sh ./build.sh x86_64-w64-mingw32.static /root/.opam/5.1.1 /root/.opam/5.1.1/lib/flexdll-windows
# exit-code 1
# env-file ~/.opam/log/ocaml-windows64-907200-231d04.env
# output-file ~/.opam/log/ocaml-windows64-907200-231d04.out
### output ###
# [...]
# checking if libtool supports shared libraries... yes
# checking whether to build shared libraries... yes
# checking whether to build static libraries... yes
# checking how to run the C preprocessor... gcc -E
# checking C compiler vendor... gcc-14-2
# checking whether host executables can be run in the build... yes
# ./configure: line 13546: cygpath: command not found
# checking whether #! works in shell scripts... yes
# checking for flexdll sources... no
# checking for flexlink... flexlink
# checking whether flexlink works... no
# configure: error: flexlink does not work
I don't understand what cause this error. Thank you for your help