OCamlbuild fails to compile complaining implementa

2019-06-27 03:49发布

I'm trying to compile an XML-RPC server written using the xmlrpc-light library in OCaml with ocamlbuild but I get:

$ ocamlbuild server.native
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlfind ocamlopt -linkpkg -package xmlrpc-light -package unix -package threads -package netsys -thread server.cmx -o server.native
File "_none_", line 1, characters 0-1:
Error: No implementations provided for the following modules:
         Netsys referenced from /usr/lib/ocaml/equeue/equeue.cmxa(Uq_engines)
Command exited with code 2.
Compilation unsuccessful after building 4 targets (3 cached) in 00:00:00.

Note that I have a myocamlbuild.ml file like this one and a _tags file containing a single line:

<server.ml> or <server.native>: pkg_unix,pkg_netsys,pkg_xmlrpc-light,pkg_threads

This plugin has worked fine for me in other cases (for client.native of the same client/server application, for example) but not for server.native. The complaint suggests that the library Netsys is not available to the compiler. But we get

$ ocamlfind query netsys
/usr/lib/ocaml/netsys

meaning that netsys is installed in /usr/lib/ocaml/netsys. Inspecting that directory gives me:

$ ls /usr/lib/ocaml/netsys
META  libnetsys.a  netsys.a  netsys.cma  netsys.cmi  netsys.cmxa  netsys.mli

Also,

$ ocamlfind list | grep netsys
netsys              (version: 2.2.9)

So, there is indeed a library called netsys installed, it does have a cmxa file ready to be used, but for some strange reason, ocamlbuild complaints that there is no implementation provided for the module Netsys. The fact that ocamlbuild could read /usr/lib/ocaml/equeue/equeue.cmxa should be enough to conclude that everything should be fine regarding environment ($PATH, etc.) in terms of finding libraries.

This is all in Debian 6.0 and my OCaml's version is 3.11.2.

After some browsing, I found an svn commit message (repository diff) which suggests that it may have to do with the number of threads used. And, in fact, I'm using a Mutex somewhere in my code (check the code of server.ml and client.ml in this other question). If I remove the Mutex stuff from my server.ml the error still happens. But if I additionally remove the pkg_threads from the _tags file then everything compiles. So, my conclusion is that I can't directly use the threads library with xmlrpc-light, which is weird.

1条回答
Melony?
2楼-- · 2019-06-27 04:13

IMHO equeue META is wrong. Adding netsys to dependencies fixes your issue :

sed -i 's/threads/netsys,threads/' /usr/lib/ocaml/equeue/META
查看更多
登录 后发表回答