I am trying to run Liquidsoap on OnmiOS/Illumos. I have had some problems using the NetBSD pkgsrc ports so for now I have managed to build the latest OCaml 4.09.0 from source. I had to modify the configure script some and the Makefile.config some but I managed to get it compiled and installed along with OPAM. I got the point of installing packages and while most build and install correctly, I am encountering the following problem with a few packages which is completely out of my realm of understanding. It looks like this:
---------------------------------------------------------------------
# opam install liquidsoap
The following actions will be performed:
∗ install menhir 20190924 [required by liquidsoap]
∗ install liquidsoap 1.4.0
===== ∗ 2 =====
Do you want to continue? [Y/n] y
#=== ERROR while compiling menhir.20190924 ====================================#
# context 2.0.5 | sunos/i86pc | ocaml-system.4.09.0 | https://opam.ocaml.org#e3f0a41f
# path ~/.opam/default/.opam-switch/build/menhir.20190924
# command /opt/local/bin/make -f Makefile PREFIX=/home/owensmk/.opam/default USE_OCAMLFIND=true docdir=/home/owensmk/.opam/default/doc/menhir libdir=/home/owensmk/.opam/default/lib/menhir mandir=/home/owensmk/.opam/default/man/man1
# exit-code 2
# env-file ~/.opam/log/menhir-15767-ad8886.env
# output-file ~/.opam/log/menhir-15767-ad8886.out
### output ###
# [...]
# ocamlopt.opt -a menhirLib.cmx -o menhirLib.cmxa
# ocamlopt.opt -shared -linkall menhirLib.cmxa -o menhirLib.cmxs
# + ocamlopt.opt -shared -linkall menhirLib.cmxa -o menhirLib.cmxs
# sh: line 1: shared-libs-not-available: not found
# File "caml_startup", line 1:
# Error: I/O error: shared-libs-not-available -o 'menhirLib.cmxs' '-L/opt/local/lib/ocaml' 'menhirLib.cmxs.startup.o' 'menhirLib.a'
# Command exited with code 2.
# make[2]: *** [Makefile:44: stage1] Error 10
# make[2]: Leaving directory '/home/owensmk/.opam/default/.opam-switch/build/menhir.20190924/src'
# make[1]: *** [Makefile:34: bootstrap] Error 2
# make[1]: Leaving directory '/home/owensmk/.opam/default/.opam-switch/build/menhir.20190924/src'
# make: *** [Makefile:120: all] Error 2
--------------------------------------------------------------
Basically ocamlopt.opt is passing “-shared” in the build and its responding with “shared-libs-not-available.” If I manually run this without that switch, it will compile that single module.
My question is, how do I fix this? Is the -shared switch originating from the OPAM build, OCaml build, my environmental settings, etc. What should I do to properly address this so I can build these. Do I need to rebuild OCaml differently somehow?
I am completely new to OCaml. I know very little about the language or tools. My main goal is to get Liquidsoap running, which I think I am close to doing if I can get past this one snag. Any help would be greatly appreciated. I am hoping I can integrate these fixes into the NetBSD pkgsrc so OCaml/OPAM and Liquidsoap can run on SmartOS and OmniOS.
# sh: line 1: shared-libs-not-available: not found
Looking at the configure script, it looks like the variable mksharedlib isn’t set properly as it stayed at its initial value. It should be set depending on the value of $host. Could you get the value in your case ? Then see why it’s not set properly.
I got everything built and installed. The shared library problem as gone away.
However now I am running into not being able to set default include and library search path. When building with opam now I need to tell it to include /opt/local/include for headers and /opt/local/lib for libraries. I set my CFLAGS and LDFLAG environmental variables but that does not seem to help.
Ok, I found the problem. In building, opam is honoring CFLAGS and LDFLAGS, but the failure was with caml_startup, as it is not looking in /opt/local/lib:
cd ~/.opam/default/.opam-switch/build/lame.0.3.3
make
make -C src all
make[1]: Entering directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
[ ! -f lame.cmx ] || mv lame.cmx lame.cmx.old
make[2]: Entering directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
make[2]: 'liblame_stubs.a' is up to date.
make[2]: 'lame.cma' is up to date.
make[2]: Leaving directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
ocamlopt.opt -g -w +A@5-7@8@11@12@20-35-44-45 -cclib -lmp3lame -cclib -lm -shared lame.ml lame_stubs.o -o lame.cmxs
make[2]: Entering directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
make[2]: 'liblame_stubs.a' is up to date.
ocamlopt.opt -c -g -w +A@5-7@8@11@12@20-35-44-45 lame.ml
ocamlopt.opt -a -ccopt -L/opt/local/lib -ccopt -L/opt/local/lib -cclib -llame_stubs -cclib -lmp3lame -cclib -lm \
-o lame.cmxa lame.cmx
ld: fatal: library -lmp3lame: not found
ld: fatal: file processing errors. No output written to lame.cmxs
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
make[1]: *** [Makefile:62: lame.cmxs] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
make[1]: Leaving directory '/home/owensmk/.opam/default/.opam-switch/build/lame.0.3.3/src'
make: *** [Makefile:10: all] Error 2
But setting LD_LIBRARY_PATH fixed that. So it looks like opam is finally building the packages I had trouble with yesterday.