You have at least 2 ways to pass your parameters to ocamlbuild so that it picks up your library:
You can use ocamlbuild command line options:
$ ocamlbuild -cflags '-I /path/to/mylibrary' -lflags '-I /path/to/mylibrary mylibrary.cma' myprogram.byte
Replace .cma with .cmxa for your own executable.
Use the myocamlbuild.ml file so that ocamlbuild "knows" about the library and marks the files that need it in the _tag file:
In myocamlbuild.ml :
open Ocamlbuild_plugin open Command dispatch begin function | After_rules -> ocaml_lib ~extern:true ~dir:"/path/to/mylibrary" "mylibrary" | _ -> ()
In _tags :
<glob pattern>: use_mylibrary
The ocaml_lib command in myocamlbuild.ml tells the tool that a library named "mylibrary" (with specific implementations ending in .cma or .cmxa or others - profiling, plugins) is located in the directory "/ path / to / MyLibrary".
All files matching the glob pattern in the project directory will be linked using "mylibrary" on ocamlbuild and compiled using special parameters (so you donโt have to worry about the native or byte of the target). Example:
<src/somefile.ml>: use_mylibrary
Note: if the library is located in a path known to the compiler (usually /usr/lib/ocaml or /usr/local/lib/ocaml ), then the path prefix can be safely replaced with + , therefore /usr/lib/ocaml/mylibrary becomes +mylibrary >.
source share