Stdlib directory relative to the compiler bins

Hello,

Ocaml compiler(s) I built from source code seems to be looking for the stdlib at a fixed path ($prefix/lib/ocaml), and if I move everything under $prefix/ to another directory on another machine to share with other people, it can’t find the stdlib (I can fix this with -I parameter, but I don’t want to communicate this through docs etc). Is there a way to compile it in a way so that stdlib is searched at …/lib/ocaml relative to ocamlopt.opt.

I’ve tried

$ ./configure -prefix /usr/local -libdir ../lib/ocaml
Configuring OCaml version 4.07.1
[ERROR!] The -libdir directory must be absolute or relative to $(PREFIX).

I’m not sure how to interpret the last bit of the error. How is it going to be useful to say /usr/local/../lib/ocaml? I’ve tried this too without much hope, even though configure ended with a little hope (it didn’t resolve early to /usr/lib/ocaml):

    standard library.......... /usr/local/../lib/ocaml

and the build went fine, but make install did what I was afraid of:

mkdir -p "/usr/local/bin"
mkdir -p "/usr/local/../lib/ocaml"
mkdir -p "/usr/local/../lib/ocaml/stublibs"
mkdir -p "/usr/local/../lib/ocaml/compiler-libs"

Do you have any suggestions?

Setting the environment variable OCAMLLIB to the location of the lib directory on the target machine should work.

1 Like

(to answer your question: no, there isn’t, AFAIK, any way to use a relative path for the stdlib directory)

1 Like