Skip to content
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

Fail to build ocaml-windows with mxe: "flexlink does not work" #327

Open
Jo-Blade opened this issue Sep 1, 2024 · 2 comments
Open

Fail to build ocaml-windows with mxe: "flexlink does not work" #327

Jo-Blade opened this issue Sep 1, 2024 · 2 comments

Comments

@Jo-Blade
Copy link

Jo-Blade commented Sep 1, 2024

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:

  1. 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
  1. 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

@toots
Copy link
Member

toots commented Sep 1, 2024

The first error is because your local ocaml compiler version does not match the version of the cross-compiler you are trying to build.

The second seems to indicate another flexlink install.

Are you installing from a fresh opam switch? Did you make sure that you do not have a system-wide or any other OCaml install on your system.

A good way to start is to use a docker container. This way you are sure that you are starting from a clean slate.

@Jo-Blade
Copy link
Author

Jo-Blade commented Sep 2, 2024

The first error is because your local ocaml compiler version does not match the version of the cross-compiler you are trying to build.

The second seems to indicate another flexlink install.

Are you installing from a fresh opam switch? Did you make sure that you do not have a system-wide or any other OCaml install on your system.

A good way to start is to use a docker container. This way you are sure that you are starting from a clean slate.

Yes, I indeed work inside an archlinux docker container so the state should be clean.

In fact I ended by recompiling openssl myself using the cross-compiler from pacman and it seemed to work (at least it runs inside wine. I need to test in an actual windows).

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

No branches or pull requests

2 participants