ocamlocamlfindoasis

Compiling with external library (OASIS, OCamlfind)


I have a new project I'm trying to compile with OASIS. All my packages but one are installed with opam.

My _oasis file looks like this :

(* usual package fields *)

Executable myexe
  Path:       src
  BuildTools: ocamlbuild
  MainIs:     myexe.ml
  BuildDepends:
        some_packages_installed_with_opam
        mylocalpackage

I tried oasis setup then ./configure but OCamlfind answered that it couldn't find mylocalpackage. So I decided to take a look at where OCamlfind looks for packages and found out that you can set an OCAMLPATH variable to add directories where packages might be installed. So I did export OCAMLPATH=path_to_mylocalpackage:$OCAMLPATH and tried again.

oasis setup gives me this result :

findlib: [WARNING] While parsing 'path_to_my_local_package/META.in': 
         The `directory' directive is required in this META definition

and ocamlfind query mylocalpackage gives me this result :

ocamlfind: Package `mylocalpackage' not found

I don't know if I should write in _oasis where to find this package or if changing the OCAMLPATH variable is the solution. But if it is, I don't understand the warning.


Steps to reproduce

For those who would like to try it :


Solution

  • Well, this is a pretty non-standard approach that you're trying. Not sure, why you need it, as usually it is better just to install the package. Anyway, when you're using the OCAMLPATH variable you need to pass it a path to the lib folder, that contains folders that, respectively, contains the META files. I'm having the following repository structure:

    .
    ├── proj
    └── why3-0.88.3
    

    and in the proj folder, I'm running the configure script with the following OCAMLPATH:

    OCAMLPATH=../why3-0.88.3/lib/:$OCAMLPATH ./configure
    

    After that everything works, and you don't even need to pass the OCAMLPATH variable anymore to the compilation, linking, or execution stages.