2

I'm doing a project in OCaml and I'm trying to use Ocamlnet. I'm using ocamlbuild for the build. Here's my build command line:

ocamlbuild -use-ocamlfind -pkgs threads,yojson,str,postgresql,netcgi2 \
  -cflags -g,-thread -lflags -g,-thread -classic-display test.byte

When I build my project, I'm getting this link error:

+ /usr/bin/ocamlfind ocamlc -g -thread -linkpkg -package netcgi2 -package postgresql -package str -package threads -package yojson cgi.cmo data.cmo util.cmo persist.cmo setup.cmo test.cmo -o test.byte
File "_none_", line 1, characters 0-1:
Error: Error while linking /usr/lib/ocaml/netsys/netsys.cma(Netsys_posix):
The external function `netsys_have_sem' is not available
Command exited with code 2.

I'm not using anything from Netsys_posix directly, but my code references Netchannels and Netcgi_cgi.

I'm using Debian Wheezy (7) and installing packages with the distro package manager. The version of OCaml is 3.12.1. Here's the list of OCaml-related packages I have installed, in case it's relevant (apologies for running them all together on one line, but putting each on its own line seemed like an excessive use of space):

libapache2-mod-ocamlnet libbatteries-ocaml-dev libbatteries-ocaml-doc libbiniou-ocaml libbiniou-ocaml-dev libcalendar-ocaml libcalendar-ocaml-dev libcamomile-ocaml-data libcamomile-ocaml-dev libcryptgps-ocaml-dev libcryptokit-ocaml libcryptokit-ocaml-dev libcsv-ocaml-dev libderiving-ocsigen-ocaml libderiving-ocsigen-ocaml-dev libeasy-format-ocaml libeasy-format-ocaml-dev libeliom-ocaml libeliom-ocaml-dev libfindlib-ocaml libfindlib-ocaml-dev libjs-of-ocaml libjs-of-ocaml-dev liblwt-ocaml liblwt-ocaml-dev liblwt-ocaml-doc liblwt-ssl-ocaml liblwt-ssl-ocaml-dev libnethttpd-ocaml-dev libocamlnet-ocaml libocamlnet-ocaml-dev libocamlnet-ocaml-doc libocsigen-ocaml libocsigen-ocaml-doc libocsigen-xhtml-ocaml-dev libocsigenserver-ocaml libocsigenserver-ocaml-dev libpcre-ocaml libpcre-ocaml-dev libpostgresql-ocaml libpostgresql-ocaml-dev libreact-ocaml libreact-ocaml-dev libsqlite3-ocaml libsqlite3-ocaml-dev libssl-ocaml libssl-ocaml-dev libtext-ocaml libtext-ocaml-dev libtyxml-ocaml libtyxml-ocaml-dev libyojson-ocaml libyojson-ocaml-dev libzip-ocaml libzip-ocaml-dev ocaml ocaml-base ocaml-base-nox ocaml-batteries-included ocaml-findlib ocaml-interp ocaml-nox ocamlduce ocamlduce-base

How can I get my build to work?

Is this an error on my part (in my build) or is it a Debian packaging bug?


UPDATE:

I downloaded the latest OCaml (4.01.0) and OPAM (1.1.1), built them from source and installed them in /opt, then used OPAM to install the needed libraries. Now I get a very similar result but naming a different missing function:

+ ocamlfind ocamlc -g -thread -linkpkg -package netsys -package netcgi2 -package postgresql -package str -package yojson -package threads cgi.cmo data.cmo util.cmo persist.cmo setup.cmo test.cmo -o test.byte
File "_none_", line 1:
Error: Error while linking /home/nate/.opam/system/lib/netsys/netsys.cma(Netsys_posix):
The external function `caml_ba_dim_1' is not available
Command exited with code 2.
Nate C-K
  • 5,744
  • 2
  • 29
  • 45
  • That particular external function should be included with the ocamlnet distribution. where the failing is, I'm not sure. – nlucaroni Mar 04 '14 at 14:53
  • For now I'm going to try installing the stock versions of OCaml and the necessary libraries in a separate tree and see if that makes everything work better. – Nate C-K Mar 04 '14 at 15:12
  • if debian did screw up the packaging, you can try installing through OPAM. – nlucaroni Mar 04 '14 at 15:31
  • @nlucaroni: I tried that, now it complains about `caml_ba_dim_1` instead. (I updated the question above.) – Nate C-K Mar 04 '14 at 16:47
  • well, that's an improvement! Thats in the bigarray package --it comes with ocaml, but needs to be included as an additional package dependency. – nlucaroni Mar 04 '14 at 17:48
  • 1
    @nlucaroni: Adding a dependency on bigarray still didn't fix it. I googled a bit more and found this: http://www.robertjakob.de/posts/camlbadim.html Following his advice and removing `/usr/lib/ocaml/stublibs` from my `$CAML_LD_LIBRARY_PATH` fixed the problem, and my code now builds successfully! Thanks for your help on this. – Nate C-K Mar 04 '14 at 18:43

0 Answers0