ocaml-cross/opam-cross-windows

Error on building ocaml-windows

Closed this issue · 5 comments

jackprograms@pop-os:~/Desktop/OCaml Projects/OCaml Playground$ opam install ocaml-windows
The following actions will be performed:
  ∗ install conf-gcc-windows32 1      [required by conf-gcc-windows, ocaml-windows32]
  ∗ install flexdll-windows    0.37   [required by ocaml-windows32]
  ∗ install conf-gcc-windows   1      [required by ocaml-windows]
  ∗ install ocaml-windows32    4.11.2 [required by ocaml-windows]
  ∗ install ocaml-windows      4.11.2
===== ∗ 5 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[flexdll-windows.0.37] downloaded from https://github.com/alainfrisch/flexdll/archive/0.37.tar.gz
[ocaml-windows32.4.11.2] downloaded from https://github.com/ocaml/ocaml/archive/4.11.2.tar.gz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of conf-gcc-windows32 failed at "/home/jackprograms/.opam/opam-init/hooks/sandbox.sh build sh -exc ${TOOLPREF32-i686-w64-mingw32-}gcc --version".

#=== ERROR while compiling conf-gcc-windows32.1 ===============================#
# context     2.0.5 | linux/x86_64 | ocaml-system.4.08.1 | git://github.com/ocaml-cross/opam-cross-windows
# path        ~/.opam/default/.opam-switch/build/conf-gcc-windows32.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build sh -exc ${TOOLPREF32-i686-w64-mingw32-}gcc --version
# exit-code   127
# env-file    ~/.opam/log/conf-gcc-windows32-7951-d474c2.env
# output-file ~/.opam/log/conf-gcc-windows32-7951-d474c2.out
### output ###
# + i686-w64-mingw32-gcc --version
# sh: 1: i686-w64-mingw32-gcc: not found



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build conf-gcc-windows32 1
└─ 
╶─ No changes have been performed

I get this error when I put in opam install ocaml-windows.

I done opam install conf-flambda-windows before, and opam repository add windows git://github.com/ocaml-cross/opam-cross-windows before as well.

Can someone explain why this fails to build? Or what I can do?

Did you install both gcc-mingw-w64-i686 and gcc-mingw-w64-x86-64 as listed in Prerequisites?

jackprograms@pop-os:~$ opam install ocaml-windows
The following actions will be performed:
  ∗ install ocaml-windows32 4.11.2 [required by ocaml-windows]
  ∗ install ocaml-windows   4.11.2
===== ∗ 2 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-windows32.4.11.2] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of ocaml-windows32 failed at "/home/jackprograms/.opam/opam-init/hooks/sandbox.sh build /bin/sh ./build.sh i686-w64-mingw32".

#=== ERROR while compiling ocaml-windows32.4.11.2 =============================#
# context     2.0.5 | linux/x86_64 | ocaml-system.4.08.1 | git://github.com/ocaml-cross/opam-cross-windows
# path        ~/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build /bin/sh ./build.sh i686-w64-mingw32
# exit-code   2
# env-file    ~/.opam/log/ocaml-windows32-19868-e0ba4f.env
# output-file ~/.opam/log/ocaml-windows32-19868-e0ba4f.out
### output ###
# [...]
# /home/jackprograms/.opam/default/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 
# /home/jackprograms/.opam/default/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 '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/runtime'
# cp runtime/ocamlrun.exe boot/ocamlrun.exe
# make -C stdlib  \
#   CAMLC='$(BOOT_OCAMLC) -use-prims ../runtime/primitives' all
# make[1]: Entering directory '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/stdlib'
# /home/jackprograms/.opam/default/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 -safe-string -strict-formats  -nopervasives -c camlinternalFormatBasics.mli
# make[1]: /home/jackprograms/.opam/default/bin/ocamlrun: Command not found
# make[1]: *** [Makefile:209: camlinternalFormatBasics.cmi] Error 127
# make[1]: Leaving directory '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/stdlib'
# make: *** [Makefile:153: coldstart] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-windows32 4.11.2
└─ 
╶─ No changes have been performed

I installed the mingw in the Prerequisites, but now still an error. ocamlrun is in my /usr/bin, not in my opam, which I don't understand why it should be in the opam bin.

I made a link target, so ocamlrun is added in the opam bin, so it should target to the /usr/bin/ocamlrun.

I ran the opam install ocaml-windows again, but another error...

jackprograms@pop-os:~$ opam install ocaml-windows
The following actions will be performed:
  ∗ install ocaml-windows32 4.11.2 [required by ocaml-windows]
  ∗ install ocaml-windows   4.11.2
===== ∗ 2 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-windows32.4.11.2] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of ocaml-windows32 failed at "/home/jackprograms/.opam/opam-init/hooks/sandbox.sh build /bin/sh ./build.sh i686-w64-mingw32".

#=== ERROR while compiling ocaml-windows32.4.11.2 =============================#
# context     2.0.5 | linux/x86_64 | ocaml-system.4.08.1 | git://github.com/ocaml-cross/opam-cross-windows
# path        ~/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build /bin/sh ./build.sh i686-w64-mingw32
# exit-code   2
# env-file    ~/.opam/log/ocaml-windows32-24489-e0ba4f.env
# output-file ~/.opam/log/ocaml-windows32-24489-e0ba4f.out
### output ###
# [...]
# /home/jackprograms/.opam/default/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 
# /home/jackprograms/.opam/default/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 '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/runtime'
# cp runtime/ocamlrun.exe boot/ocamlrun.exe
# make -C stdlib  \
#   CAMLC='$(BOOT_OCAMLC) -use-prims ../runtime/primitives' all
# make[1]: Entering directory '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/stdlib'
# /home/jackprograms/.opam/default/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 -safe-string -strict-formats  -nopervasives -c camlinternalFormatBasics.mli
# Fatal error: the file '../boot/ocamlc' has not the right magic number: expected Caml1999X025, got Caml1999X028
# make[1]: *** [Makefile:209: camlinternalFormatBasics.cmi] Error 2
# make[1]: Leaving directory '/home/jackprograms/.opam/default/.opam-switch/build/ocaml-windows32.4.11.2/stdlib'
# make: *** [Makefile:153: coldstart] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-windows32 4.11.2
└─ 
╶─ No changes have been performed

It is some weird error that I don't understand.

Can someone explain why this fails to build? What can I do?

Are you trying to install 64 bit? If so, try getting rid of the link target and run opam install ocaml-windows64.

I put my OCaml compiler to 4.11.2, and it worked. Other versions like 4.11.1 and 4.08 did not work and errored, so I find the README.md misleading. Thank you for your help @BarronRauEA