I am following a fairly straightforward tutorial for setting up an OCaml development environment for a university course which has me doing the following steps:
OCaml is well-supported in macOS, so the installation process is fairly straightforward.
- Install the Homebrew package manager for macOS.
- Install the following system packages using Homebrew:
brew install make m4 gcc pkg-config fswatch
- Next, install the
opam
package manager for installing and maintaining different OCaml libraries. Execute the following lines from the terminal:
brew install opam
opam init -y --compiler=5.1.0
eval $(opam env)
opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server
opam user-setup install
- Once done, add the following line to your
~/.bashrc
,~/.zshrc
, and/or~/.profile
files (if they exist, otherwise create the file as appropriate for your shell, e.g.,~/.bashrc
):
eval $(opam env)
- Close your terminal window and start a new one.To check that your OCaml is correctly installed, run
ocamlc --version
from the terminal. You should get the output5.1.0
, which is the version of the OCaml compiler we have just installed.
Except when I run the opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server
command I am greeted with the following terminal output:
β opam install -y dune utop num menhir user-setup ocamlformat ocamlformat-rpc ocaml-lsp-server
[NOTE] Package ocamlformat-rpc is already installed (current version is removed).
[NOTE] Package dune is already installed (current version is 3.12.2).
Constructing initial basis...
Number of 0-1 knapsack inequalities = 6202
Constructing conflict graph...
Conflict graph has 1161 + 337 = 1498 vertices
The following actions will be performed:
β install cppo 1.6.9 [required by utop]
β install spawn v0.15.1 [required by ocaml-lsp-server]
β install xdg 3.12.2 [required by ocaml-lsp-server, utop]
β install num 1.5
β install menhirSdk 20231231 [required by menhir]
β install ocamlfind 1.9.6 [required by user-setup, utop]
β install menhirLib 20231231 [required by menhir]
β install dune-build-info 3.12.2 [required by ocaml-lsp-server]
β install re 1.11.0 [required by ocamlformat, ocaml-lsp-server, user-setup]
β install chrome-trace 3.12.2 [required by ocaml-lsp-server]
β install menhirCST 20231231 [required by menhir]
β install trie 1.0.0 [required by mew]
β install either 1.0.0 [required by ocamlformat-lib]
β install pp 1.2.0 [required by ocaml-lsp-server]
β install ocaml-version 3.6.3 [required by ocamlformat-lib]
β install result 1.5 [required by ocamlformat-lib]
β install csexp 1.5.2 [required by ocaml-lsp-server]
β install ordering 3.12.2 [required by ocaml-lsp-server]
β install camlp-streams 5.0.1 [required by ocaml-lsp-server]
β install sexplib0 v0.16.0 [required by base]
β install fix 20230505 [required by ocamlformat-lib]
β install yojson 2.1.2 [required by ocaml-lsp-server]
β install topkg 1.0.7 [required by astring, uutf]
β install base-bytes base [required by ocp-indent]
β install menhir 20231231
β install mew 0.1.0 [required by mew_vi]
β install ocamlformat-rpc-lib 0.26.1 [required by ocaml-lsp-server]
β install merlin-lib 4.13-501 [required by ocaml-lsp-server]
β install dune-configurator 3.12.2 [required by base]
β install dyn 3.12.2 [required by ocaml-lsp-server]
β install ppx_yojson_conv_lib v0.16.0 [required by ocaml-lsp-server]
β install uutf 1.0.3 [required by ocaml-lsp-server]
β install uucp 15.1.0 [required by uuseg, zed]
β install react 1.2.2 [required by utop]
β install astring 0.8.5 [required by ocaml-lsp-server]
β install ocplib-endian 1.2 [required by lwt]
β install ocp-indent 1.8.1 [required by user-setup]
β install base v0.16.3 [required by ocamlformat-lib]
β install stdune 3.12.2 [required by ocaml-lsp-server]
β install ocamlc-loc 3.12.2 [required by ocaml-lsp-server]
β install uuseg 15.1.0 [required by ocamlformat-lib]
β install mew_vi 0.5.0 [required by lambda-term]
β install fpath 0.7.3 [required by ocamlformat-lib]
β install lwt 5.7.0 [required by utop]
β install user-setup 0.7
β install stdio v0.16.0 [required by ocamlformat-lib]
β install fiber 3.7.0 [required by ocaml-lsp-server]
β install dune-rpc 3.12.2 [required by ocaml-lsp-server]
β install zed 3.2.3 [required by utop]
β install lwt_react 1.2.0 [required by utop]
β install logs 0.7.0 [required by utop]
β install ocamlformat-lib 0.26.1 [required by ocamlformat]
β install ocaml-lsp-server 1.17.0
β install lambda-term 3.3.2 [required by utop]
β install ocamlformat 0.26.1
β install utop 2.13.1
===== β 56 =====
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> π«
β¬ retrieved astring.0.8.5 (cached)
β¬ retrieved camlp-streams.5.0.1 (cached)
β¬ retrieved cppo.1.6.9 (cached)
β¬ retrieved csexp.1.5.2 (cached)
β¬ retrieved chrome-trace.3.12.2 (cached)
β¬ retrieved dune-configurator.3.12.2 (cached)
[ERROR] The compilation of csexp.1.5.2 failed at "dune build -p csexp -j 11 @install".
β¬ retrieved dune-build-info.3.12.2 (cached)
β¬ retrieved dyn.3.12.2 (cached)
β¬ retrieved either.1.0.0 (cached)
β¬ retrieved fiber.3.7.0 (cached)
β¬ retrieved dune-rpc.3.12.2 (cached)
[ERROR] The compilation of dune-build-info.3.12.2 failed at "dune build -p dune-build-info -j 11 @install".
β¬ retrieved fix.20230505 (cached)
β¬ retrieved lambda-term.3.3.2 (cached)
β¬ retrieved fpath.0.7.3 (cached)
β¬ retrieved logs.0.7.0 (cached)
[ERROR] The compilation of either.1.0.0 failed at "dune build -p either -j 11 @install".
[ERROR] The compilation of chrome-trace.3.12.2 failed at "dune build -p chrome-trace -j 11 @install".
β installed cppo.1.6.9
β¬ retrieved lwt.5.7.0 (cached)
β¬ retrieved lwt_react.1.2.0 (cached)
β¬ retrieved menhir.20231231 (cached)
β¬ retrieved menhirCST.20231231 (cached)
β¬ retrieved menhirSdk.20231231 (cached)
[ERROR] The compilation of menhirCST.20231231 failed at "dune build -p menhirCST -j 11".
β¬ retrieved menhirLib.20231231 (cached)
β¬ retrieved mew.0.1.0 (cached)
β¬ retrieved merlin-lib.4.13-501 (cached)
β¬ retrieved mew_vi.0.5.0 (cached)
β¬ retrieved num.1.5 (cached)
β¬ retrieved ocaml-version.3.6.3 (cached)
β¬ retrieved ocaml-lsp-server.1.17.0 (cached)
[ERROR] The compilation of menhirLib.20231231 failed at "dune build -p menhirLib -j 11".
[ERROR] The compilation of menhirSdk.20231231 failed at "dune build -p menhirSdk -j 11".
[ERROR] The compilation of fix.20230505 failed at "dune build -p fix -j 11".
[ERROR] The compilation of camlp-streams.5.0.1 failed at "dune build -p camlp-streams -j 11 @install".
β¬ retrieved base.v0.16.3 (cached)
β¬ retrieved ocamlfind.1.9.6 (cached)
β¬ retrieved ocamlformat.0.26.1 (cached)
β¬ retrieved ocamlformat-lib.0.26.1 (cached)
β¬ retrieved ocamlformat-rpc-lib.0.26.1 (cached)
β¬ retrieved ocp-indent.1.8.1 (cached)
β¬ retrieved ocplib-endian.1.2 (cached)
β¬ retrieved pp.1.2.0 (cached)
β¬ retrieved ppx_yojson_conv_lib.v0.16.0 (cached)
[ERROR] The compilation of ocaml-version.3.6.3 failed at "dune build -p ocaml-version -j 11 @install".
β¬ retrieved ocamlc-loc.3.12.2 (cached)
β¬ retrieved re.1.11.0 (cached)
β¬ retrieved result.1.5 (cached)
β¬ retrieved sexplib0.v0.16.0 (cached)
β¬ retrieved spawn.v0.15.1 (cached)
β¬ retrieved stdio.v0.16.0 (cached)
[ERROR] The compilation of spawn.v0.15.1 failed at "dune build -p spawn -j 11 @install".
[ERROR] The compilation of result.1.5 failed at "dune build -p result -j 11".
β¬ retrieved react.1.2.2 (cached)
[ERROR] The compilation of pp.1.2.0 failed at "dune build -p pp -j 11 @install".
β¬ retrieved ordering.3.12.2 (cached)
β¬ retrieved trie.1.0.0 (cached)
β¬ retrieved user-setup.0.7 (cached)
[ERROR] The compilation of ocamlfind.1.9.6 failed at "make opt".
β¬ retrieved topkg.1.0.7 (cached)
β¬ retrieved utop.2.13.1 (cached)
β¬ retrieved stdune.3.12.2 (cached)
β¬ retrieved uuseg.15.1.0 (cached)
β¬ retrieved uutf.1.0.3 (cached)
[ERROR] The compilation of ordering.3.12.2 failed at "dune build -p ordering -j 11 @install".
β¬ retrieved uucp.15.1.0 (cached)
β¬ retrieved yojson.2.1.2 (cached)
β¬ retrieved zed.3.2.3 (cached)
[ERROR] The compilation of trie.1.0.0 failed at "dune build -p trie -j 11".
[ERROR] The compilation of sexplib0.v0.16.0 failed at "dune build -p sexplib0 -j 11".
[ERROR] The compilation of re.1.11.0 failed at "dune build -p re -j 11".
[ERROR] The compilation of num.1.5 failed at "make PROFILE=release opam-modern".
β¬ retrieved xdg.3.12.2 (cached)
[ERROR] The compilation of yojson.2.1.2 failed at "dune build -p yojson -j 11 @install".
[ERROR] The compilation of xdg.3.12.2 failed at "dune build -p xdg -j 11 @install".
#=== ERROR while compiling yojson.2.1.2 =======================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/yojson.2.1.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p yojson -j 11 @install
# exit-code 1
# env-file ~/.opam/log/yojson-34019-9dbc97.env
# output-file ~/.opam/log/yojson-34019-9dbc97.out
### output ###
# [...]
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/yojson.2.1.2/_build/default/lib/yojson.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# File "bin/dune", line 2, characters 7-12:
# 2 | (name ydump)
# ^^^^^
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -o bin/ydump.exe lib/yojson.cmxa bin/.ydump.eobjs/native/dune__exe__Ydump.cmx)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/yojson.2.1.2/_build/default/lib/yojson.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling xdg.3.12.2 =========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/xdg.3.12.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p xdg -j 11 @install
# exit-code 1
# env-file ~/.opam/log/xdg-34019-889695.env
# output-file ~/.opam/log/xdg-34019-889695.out
### output ###
# [...]
# 10 | (:include c_library_flags.sexp))
# 11 | (foreign_stubs
# 12 | (language c)
# 13 | (names xdg_stubs))
# 14 | (synopsis "[Internal] XDG base directories specification implementation")
# 15 | (instrumentation
# 16 | (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/xdg -o otherlibs/xdg/xdg.cmxs otherlibs/xdg/xdg.cmxa)
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/xdg.3.12.2/_build/default/otherlibs/xdg/xdg.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/xdg.3.12.2/_build/default/otherlibs/xdg/libxdg_stubs.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling trie.1.0.0 =========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/trie.1.0.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p trie -j 11
# exit-code 1
# env-file ~/.opam/log/trie-34019-329e13.env
# output-file ~/.opam/log/trie-34019-329e13.out
### output ###
# File "src/dune", line 1, characters 0-79:
# 1 | (library
# 2 | (name trie)
# 3 | (public_name trie)
# 4 | (flags (:standard -safe-string)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -safe-string -g -shared -linkall -I src -o src/trie.cmxs src/trie.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/trie.1.0.0/_build/default/src/trie.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling spawn.v0.15.1 ======================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p spawn -j 11 @install
# exit-code 1
# env-file ~/.opam/log/spawn-34019-34bfaa.env
# output-file ~/.opam/log/spawn-34019-34bfaa.out
### output ###
# File "src/dune", line 1, characters 0-396:
# [...]
# 2 | (name spawn)
# 3 | (public_name spawn)
# ....
# 11 | ;; c_library_flags. However, this would require testing that it is
# 12 | ;; supported.
# 13 | (libraries unix threads))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/spawn.cmxs src/spawn.cmxa)
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1/_build/default/src/libspawn_stubs.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/spawn.v0.15.1/_build/default/src/spawn.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling sexplib0.v0.16.0 ===================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/sexplib0.v0.16.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p sexplib0 -j 11
# exit-code 1
# env-file ~/.opam/log/sexplib0-34019-00087f.env
# output-file ~/.opam/log/sexplib0-34019-00087f.out
### output ###
# File "src/dune", line 1, characters 0-79:
# 1 | (library (name sexplib0) (public_name sexplib0)
# 2 | (preprocess no_preprocessing))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/sexplib0.cmxs src/sexplib0.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/sexplib0.v0.16.0/_build/default/src/sexplib0.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling result.1.5 =========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/result.1.5
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p result -j 11
# exit-code 1
# env-file ~/.opam/log/result-34019-faa45e.env
# output-file ~/.opam/log/result-34019-faa45e.out
### output ###
# File "dune", line 1, characters 0-64:
# 1 | (library
# 2 | (name result)
# 3 | (public_name result)
# 4 | (modules result))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I . -o result.cmxs result.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/result.1.5/_build/default/result.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling re.1.11.0 ==========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/re.1.11.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p re -j 11
# exit-code 1
# env-file ~/.opam/log/re-34019-ce7d01.env
# output-file ~/.opam/log/re-34019-ce7d01.out
### output ###
# [...]
# 25 | (library
# 26 | (name re_posix)
# 27 | (public_name re.posix)
# 28 | (wrapped false)
# 29 | (modules re_posix)
# 30 | (synopsis "Deprecated. Use Re.Posix")
# 31 | (libraries re))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -w -50 -g -shared -linkall -I deprecated -o deprecated/re_posix.cmxs deprecated/re_posix.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/re.1.11.0/_build/default/deprecated/re_posix.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling pp.1.2.0 ===========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/pp.1.2.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p pp -j 11 @install
# exit-code 1
# env-file ~/.opam/log/pp-34019-3b7bbd.env
# output-file ~/.opam/log/pp-34019-3b7bbd.out
### output ###
# File "src/dune", line 1, characters 0-27:
# 1 | (library
# 2 | (public_name pp))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/pp.cmxs src/pp.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/pp.1.2.0/_build/default/src/pp.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling ordering.3.12.2 ====================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/ordering.3.12.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ordering -j 11 @install
# exit-code 1
# env-file ~/.opam/log/ordering-34019-d10882.env
# output-file ~/.opam/log/ordering-34019-d10882.out
### output ###
# [...]
# File "otherlibs/ordering/dune", line 1, characters 0-124:
# 1 | (library
# 2 | (name ordering)
# 3 | (public_name ordering)
# 4 | (synopsis "Element ordering.")
# 5 | (instrumentation
# 6 | (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/ordering -o otherlibs/ordering/ordering.cmxs otherlibs/ordering/ordering.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ordering.3.12.2/_build/default/otherlibs/ordering/ordering.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling ocamlfind.1.9.6 ====================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/ocamlfind.1.9.6
# command ~/.opam/opam-init/hooks/sandbox.sh build make opt
# exit-code 2
# env-file ~/.opam/log/ocamlfind-34019-0c01e7.env
# output-file ~/.opam/log/ocamlfind-34019-0c01e7.out
### output ###
# [...]
# File "frontend.ml", line 859, characters 10-39:
# 859 | Fl_package_base.package_users predicates1 packages1
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Warning 6 [labels-omitted]: label preds was omitted in the application of this function.
# ocamlopt -I +compiler-libs -g -o ocamlfind_opt findlib.cmxa unix.cmxa \
# -I +unix -I +dynlink ocaml_args.cmx frontend.cmx
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ocamlfind.1.9.6/src/findlib/findlib.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# make[1]: *** [ocamlfind_opt] Error 2
# make: *** [opt] Error 2
#=== ERROR while compiling ocaml-version.3.6.3 ================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/ocaml-version.3.6.3
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ocaml-version -j 11 @install
# exit-code 1
# env-file ~/.opam/log/ocaml-version-34019-a302cf.env
# output-file ~/.opam/log/ocaml-version-34019-a302cf.out
### output ###
# File "dune", line 1, characters 0-60:
# 1 | (library
# 2 | (name ocaml_version)
# 3 | (public_name ocaml-version))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I . -o ocaml_version.cmxs ocaml_version.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/ocaml-version.3.6.3/_build/default/ocaml_version.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling num.1.5 ============================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/num.1.5
# command ~/.opam/opam-init/hooks/sandbox.sh build make PROFILE=release opam-modern
# exit-code 2
# env-file ~/.opam/log/num-34019-0e4664.env
# output-file ~/.opam/log/num-34019-0e4664.out
### output ###
# [...]
# ocamlopt -w +a-4-9-41-42-44-45-48 -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_flags.ml
# ocamlopt -w +a-4-9-41-42-44-45-48 -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c ratio.ml
# ocamlopt -w +a-4-9-41-42-44-45-48 -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c num.ml
# ocamlopt -w +a-4-9-41-42-44-45-48 -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -c arith_status.ml
# ocamlmklib -o nums -oc nums -linkall int_misc.cmx nat.cmx big_int.cmx arith_flags.cmx ratio.cmx num.cmx arith_status.cmx
# ocamlopt -w +a-4-9-41-42-44-45-48 -bin-annot -g -safe-string -strict-sequence -strict-formats -I +compiler-libs -I . -shared -o nums.cmxs nums.cmxa
# ld: multiple errors: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/num.1.5/src/libnums.a'; archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/num.1.5/src/nums.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
# make[1]: *** [nums.cmxs] Error 2
# make: *** [all] Error 2
#=== ERROR while compiling menhirSdk.20231231 =================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/menhirSdk.20231231
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirSdk -j 11
# exit-code 1
# env-file ~/.opam/log/menhirSdk-34019-4ede18.env
# output-file ~/.opam/log/menhirSdk-34019-4ede18.out
### output ###
# File "sdk/dune", line 16, characters 0-127:
# 16 | (library
# 17 | (name menhirSdk)
# 18 | (public_name menhirSdk)
# 19 | (synopsis "Toolkit for postprocessing Menhir automata (.cmly files)")
# 20 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I sdk -o sdk/menhirSdk.cmxs sdk/menhirSdk.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirSdk.20231231/_build/default/sdk/menhirSdk.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling menhirLib.20231231 =================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/menhirLib.20231231
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirLib -j 11
# exit-code 1
# env-file ~/.opam/log/menhirLib-34019-d70bba.env
# output-file ~/.opam/log/menhirLib-34019-d70bba.out
### output ###
# [...]
# File "lib/pack/dune", line 18, characters 0-137:
# 18 | (library
# 19 | (name menhirLib)
# 20 | (public_name menhirLib)
# 21 | (synopsis "Runtime support for code generated by Menhir")
# 22 | (modules menhirLib)
# 23 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I lib/pack -o lib/pack/menhirLib.cmxs lib/pack/menhirLib.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirLib.20231231/_build/default/lib/pack/menhirLib.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling menhirCST.20231231 =================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/menhirCST.20231231
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p menhirCST -j 11
# exit-code 1
# env-file ~/.opam/log/menhirCST-34019-48a0ff.env
# output-file ~/.opam/log/menhirCST-34019-48a0ff.out
### output ###
# [...]
# File "cst/dune", line 6, characters 0-134:
# 6 | (library
# 7 | (name menhirCST)
# 8 | (public_name menhirCST)
# 9 | (synopsis "Runtime support for code generated by Menhir")
# 10 | (modules Settle)
# 11 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I cst -o cst/menhirCST.cmxs cst/menhirCST.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/menhirCST.20231231/_build/default/cst/menhirCST.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling fix.20230505 =======================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/fix.20230505
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p fix -j 11
# exit-code 1
# env-file ~/.opam/log/fix-34019-370b6c.env
# output-file ~/.opam/log/fix-34019-370b6c.out
### output ###
# File "src/dune", line 1, characters 0-118:
# 1 | (library
# 2 | (name fix)
# 3 | (public_name fix)
# 4 | (synopsis "An on-demand, incremental fixed point computation algorithm")
# 5 | )
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/fix.cmxs src/fix.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/fix.20230505/_build/default/src/fix.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling either.1.0.0 =======================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/either.1.0.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p either -j 11 @install
# exit-code 1
# env-file ~/.opam/log/either-34019-f0121f.env
# output-file ~/.opam/log/either-34019-f0121f.out
### output ###
# File "src/dune", line 1, characters 0-76:
# 1 | (library
# 2 | (name either)
# 3 | (public_name either)
# 4 | (modules either either_intf))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/either.cmxs src/either.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/either.1.0.0/_build/default/src/either.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling dune-build-info.3.12.2 =============================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/dune-build-info.3.12.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p dune-build-info -j 11 @install
# exit-code 1
# env-file ~/.opam/log/dune-build-info-34019-cd4700.env
# output-file ~/.opam/log/dune-build-info-34019-cd4700.out
### output ###
# File "otherlibs/dune-build-info/src/dune", line 1, characters 0-245:
# [...]
# 5 | (special_builtin_support
# 6 | (build_info
# 7 | (data_module build_info_data)
# 8 | (api_version 1)))
# 9 | (instrumentation
# 10 | (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/dune-build-info/src -o otherlibs/dune-build-info/src/build_info.cmxs otherlibs/dune-build-info/src/build_info.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/dune-build-info.3.12.2/_build/default/otherlibs/dune-build-info/src/build_info.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling csexp.1.5.2 ========================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/csexp.1.5.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p csexp -j 11 @install
# exit-code 1
# env-file ~/.opam/log/csexp-34019-2f1355.env
# output-file ~/.opam/log/csexp-34019-2f1355.out
### output ###
# File "src/dune", line 1, characters 0-30:
# 1 | (library
# 2 | (public_name csexp))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -g -shared -linkall -I src -o src/csexp.cmxs src/csexp.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/csexp.1.5.2/_build/default/src/csexp.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling chrome-trace.3.12.2 ================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/chrome-trace.3.12.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p chrome-trace -j 11 @install
# exit-code 1
# env-file ~/.opam/log/chrome-trace-34019-27b6d4.env
# output-file ~/.opam/log/chrome-trace-34019-27b6d4.out
### output ###
# [...]
# File "otherlibs/chrome-trace/src/dune", line 1, characters 0-174:
# 1 | (library
# 2 | (name chrome_trace)
# 3 | (public_name chrome-trace)
# 4 | (synopsis "Emit catapult trace files, compatible with chrome://tracing")
# 5 | (instrumentation
# 6 | (backend bisect_ppx)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -alert -unstable -g -shared -linkall -I otherlibs/chrome-trace/src -o otherlibs/chrome-trace/src/chrome_trace.cmxs otherlibs/chrome-trace/src/chrome_trace.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/chrome-trace.3.12.2/_build/default/otherlibs/chrome-trace/src/chrome_trace.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
#=== ERROR while compiling camlp-streams.5.0.1 ================================#
# context 2.1.5 | macos/arm64 | ocaml-system.5.1.0 | https://opam.ocaml.org#fa77046c
# path ~/.opam/5.1.0/.opam-switch/build/camlp-streams.5.0.1
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p camlp-streams -j 11 @install
# exit-code 1
# env-file ~/.opam/log/camlp-streams-34019-c5de61.env
# output-file ~/.opam/log/camlp-streams-34019-c5de61.out
### output ###
# [...]
# File "_build/.dune/default/dune", line 55, characters 0-144:
# 55 | (library
# 56 | (name camlp_streams)
# 57 | (public_name camlp-streams)
# 58 | (modules :standard)
# 59 | (wrapped false)
# 60 | (flags :standard (:include flags.sexp)))
# (cd _build/default && /opt/homebrew/bin/ocamlopt.opt -w -40 -w -9 -g -shared -linkall -I . -o camlp_streams.cmxs camlp_streams.cmxa)
# ld: archive member '/' not a mach-o file in '/Users/davidmek/.opam/5.1.0/.opam-switch/build/camlp-streams.5.0.1/_build/default/camlp_streams.a'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
ββ The following actions failed
β Ξ» build camlp-streams 5.0.1
β Ξ» build chrome-trace 3.12.2
β Ξ» build csexp 1.5.2
β Ξ» build dune-build-info 3.12.2
β Ξ» build either 1.0.0
β Ξ» build fix 20230505
β Ξ» build menhirCST 20231231
β Ξ» build menhirLib 20231231
β Ξ» build menhirSdk 20231231
β Ξ» build num 1.5
β Ξ» build ocaml-version 3.6.3
β Ξ» build ocamlfind 1.9.6
β Ξ» build ordering 3.12.2
β Ξ» build pp 1.2.0
β Ξ» build re 1.11.0
β Ξ» build result 1.5
β Ξ» build sexplib0 v0.16.0
β Ξ» build spawn v0.15.1
β Ξ» build trie 1.0.0
β Ξ» build xdg 3.12.2
β Ξ» build yojson 2.1.2
ββ
ββ The following changes have been performed (the rest was aborted)
β β install cppo 1.6.9
ββ
The former state can be restored with:
/opt/homebrew/bin/opam switch import "/Users/davidmek/.opam/5.1.0/.opam-switch/backup/state-20240112210157.export"
No one, including the course staff, can provide any meaningful suggestions about these linker errors during the build process. For reference, I am on an M2 Pro MacBook Pro on macOS 14.2.1. GCC stats below:
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I have tried uninstalling and reinstalling Xcode command line tools, and redoing each one of the steps in the instructor tutorial but to no avail. I have OCaml version 5.1.0 installed. Any suggestion on the matter would be greatly appreciated.