4

I try to compile an Ocaml project with an Ocaml version provided by Opam. My ocamlbuild, ocamlfind, and oasis seem OK :

/Users/fred/.opam/4.02.1/bin/ocamlbuild
dhcp-182-73:compil fred$ which ocamlfind
/Users/fred/.opam/4.02.1/bin/ocamlfind
dhcp-182-73:compil fred$ which oasis
/Users/fred/.opam/4.02.1/bin/oasis

But when I try to compile, it seems that a wrong version of ocamlbuild is called, and even the version of ocamlfind is right, I think that it explains why ocamlfind can't find the sexplib library.

$ make
ocaml setup.ml -build 
Finished, 0 targets (0 cached) in 00:00:00.
+ /Users/fred/.opam/system/bin/ocamlfind ocamldep -package threads -package sexplib.syntax -package core -package comparelib.syntax -modules  src/tricot/tricot.mli > src/tricot/tricot.mli.depends
ocamlfind: Package `sexplib.syntax' not found
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
E: Failure("Command ''/usr/local/bin/ocamlbuild' src/tricot/tricot.cma src/tricot/tricot.cmxa src/tricot/tricot.a src/tricot/tricot.cmxs src/compil/compil.cma src/compil/compil.cmxa src/compil/compil.a src/compil/compil.cmxs src/main.native -use-ocamlfind -tag debug' terminated with error code 10")
make: *** [build] Error 1

I've tried to tell oasis which version of ocambuild to use without success, does someone knows how it could be done ? Thanks

Godev
  • 316
  • 1
  • 4
  • 12

3 Answers3

5

Try deleting setup.data and running make again. Oasis caches the paths the first time you try to build, and doesn't update them automatically afterwards. Perhaps you tried to build it, then used opam switch, then tried to build it again?

Thomas Leonard
  • 7,068
  • 2
  • 36
  • 40
  • Thanks, it works! when I tried 'make' after that, my path for ocamlbuild and ocamlfind where pointing to my Opam repo. I think I've upgraded my version of OCaml since last time I built my project – Godev May 06 '15 at 10:37
3

You must be missing a

eval $(opam config env)

See the documentation of opam switch.

Note that normally opam's install procedure should have made so that this gets invoked automatically on new shells. You may want to run opam init again it will prompt you to agree to make changes to your .profile so that everything is in order when you start new shells.

EDIT: In fact it looks like you changed to the system switch between the two invocations you show us. So it seems that in the system switch sexp is not installed. In anycase whenever you opam switch in a shell always invoke the command I mentioned above so that the right paths are setup.

Daniel Bünzli
  • 5,119
  • 20
  • 21
  • Thanks, actually it do not see any shift.. Opam points out the 4.02.1 version, and I didn't try to change it. – Godev May 01 '15 at 16:27
  • When I check my library with Ocamlfind, it is OK : ocamlfind query sexplib /Users/fred/.opam/4.02.1/lib/sexplib And when I check with opam list, sexplib is displayed. – Godev May 01 '15 at 16:36
  • So I think that the problem comes from oasis. I've looked in my setup.data file, it is written ocamlc="/usr/local/bin/ocamlc.opt" ocamlopt="/usr/local/bin/ocamlopt.opt" ocamlbuild="/usr/local/bin/ocamlbuild" But I don't understand why it doesn't choose my version of these programs which are in /Users/fred/.opam/4.02.1/bin/ ?? – Godev May 01 '15 at 16:42
  • Well I don't know what's behind this `make` – Daniel Bünzli May 01 '15 at 22:54
  • You can find my _oasis file on [github](https://github.com/TriComp/TriComp/blob/master/compil/_oasis), but I can build my project now, thanks – Godev May 06 '15 at 10:46
0

In addition to Thomas's answer, you can discard the configuration by

ocaml setup.ml -distclean