OPAM build problem with some packages on OmniOS: shared-libs-not-available

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.

1 Like
# 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 managed to find places in configure and configure.ac to fix this problem. Now I am running into a compilation problem I did not have before:

../boot/ocamlrun ./ocamldoc -man -d stdlib_man -nostdlib \
-hide Stdlib -lib Stdlib -I ../stdlib -I ../otherlibs/str -I ../otherlibs/unix -I ../otherlibs/dynlink -I ../otherlibs/systhreads -I ../parsing -I ../utils -I ../typing -I ../bytecomp -I ../driver -I ../file_formats -I ../lambda \
-pp "gawk -v ocamldoc=true -f ../stdlib/expand_module_aliases.awk" \
-t "OCaml library" -man-mini \
-text ../stdlib/ocaml_operators.mld -text ../manual/manual/library/compiler_libs.mld \
../stdlib/pervasives.ml ../stdlib/spacetime.mli ../stdlib/arg.mli ../stdlib/array.mli ../stdlib/arrayLabels.mli ../stdlib/bigarray.mli ../stdlib/bool.mli ../stdlib/buffer.mli ../stdlib/bytes.mli ../stdlib/bytesLabels.mli ../stdlib/callback.mli ../stdlib/camlinternalFormat.mli ../stdlib/camlinternalFormatBasics.mli ../stdlib/camlinternalLazy.mli ../stdlib/camlinternalMod.mli ../stdlib/camlinternalOO.mli ../stdlib/char.mli ../stdlib/complex.mli ../stdlib/digest.mli ../stdlib/ephemeron.mli ../stdlib/filename.mli ../stdlib/float.mli ../stdlib/format.mli ../stdlib/fun.mli ../stdlib/gc.mli ../stdlib/genlex.mli ../stdlib/hashtbl.mli ../stdlib/int.mli ../stdlib/int32.mli ../stdlib/int64.mli ../stdlib/lazy.mli ../stdlib/lexing.mli ../stdlib/list.mli ../stdlib/listLabels.mli ../stdlib/map.mli ../stdlib/marshal.mli ../stdlib/moreLabels.mli ../stdlib/nativeint.mli ../stdlib/obj.mli ../stdlib/oo.mli ../stdlib/option.mli ../stdlib/parsing.mli ../stdlib/printexc.mli ../stdlib/printf.mli ../stdlib/queue.mli ../stdlib/random.mli ../stdlib/result.mli ../stdlib/scanf.mli ../stdlib/seq.mli ../stdlib/set.mli ../stdlib/stack.mli ../stdlib/stdLabels.mli ../stdlib/stdlib.mli ../stdlib/stream.mli ../stdlib/string.mli ../stdlib/stringLabels.mli ../stdlib/sys.mli ../stdlib/uchar.mli ../stdlib/unit.mli ../stdlib/weak.mli ../otherlibs/str/str.mli ../otherlibs/unix/unix.mli ../otherlibs/unix/unixLabels.mli ../otherlibs/systhreads/thread.mli ../otherlibs/systhreads/condition.mli ../otherlibs/systhreads/mutex.mli ../otherlibs/systhreads/event.mli ../otherlibs/systhreads/threadUnix.mli ../otherlibs/dynlink/dynlink.mli ../parsing/ast_invariants.mli ../parsing/asttypes.mli ../parsing/builtin_attributes.mli ../parsing/depend.mli ../parsing/docstrings.mli ../parsing/parser.mli ../parsing/longident.mli ../parsing/lexer.mli ../parsing/parsetree.mli ../parsing/attr_helper.mli ../parsing/syntaxerr.mli ../parsing/location.mli ../parsing/parse.mli ../parsing/pprintast.mli ../parsing/ast_helper.mli ../parsing/printast.mli ../parsing/ast_mapper.mli ../parsing/camlinternalMenhirLib.mli ../parsing/ast_iterator.mli ../utils/config.mli ../utils/warnings.mli ../utils/consistbl.mli ../utils/misc.mli ../utils/numbers.mli ../utils/targetint.mli ../utils/profile.mli ../utils/int_replace_polymorphic_compare.mli ../utils/build_path_prefix_map.mli ../utils/identifiable.mli ../utils/load_path.mli ../utils/strongly_connected_components.mli ../utils/ccomp.mli ../utils/arg_helper.mli ../utils/clflags.mli ../utils/terminfo.mli ../driver/pparse.mli
Fatal error: cannot load shared library dllunix
Reason: ld.so.1: ocamlrun: fatal: dllunix.so: open failed: No such file or directory
make[3]: *** [Makefile:407: stdlib_man/Stdlib.3o] Error 2
make[3]: Leaving directory '/var/data/tmp/ocaml-4.09.0/ocamldoc'
make[2]: *** [Makefile:1092: ocamldoc] Error 2
make[2]: Leaving directory '/var/data/tmp/ocaml-4.09.0'
make[1]: *** [Makefile:419: opt.opt] Error 2
make[1]: Leaving directory '/var/data/tmp/ocaml-4.09.0'
make: *** [Makefile:468: world.opt] Error 2

Yet there is a shared library otherlibs/unix/dllunix.so. So somehow the linker path is not specified or wrong.

Well I just fixed that by hacking my LD_LIBRARY_PATH adding the directories in otherlibs/unix and friends but I doubt that is a good general solution.

I am thinking I may need to break down and read the Autotools books I got in No Starch Press’s Humble Bundle this week.

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

Done. Made pull request on github.