I'm not familiar with omake
but I believe flag to ocamlc
you are looking for is dllpath
:
-dllpath dir
Adds the directory dir to the run-time search path for shared C libraries. At link-
time, shared libraries are searched in the standard search path (the one corresponding
to the -I option). The -dllpath option simply stores dir in the produced executable
file, where ocamlrun(1) can find it and use it.
If you can configure omake
to pass the appropriate -dllpath
argument to ocamlc, you should be good to go.
Under the hood I believe this is using the rpath
feature (runtime library search path) of ld
, the GNU linker. See https://linux.die.net/man/1/ld . There is also a chrpath
utility to change the rpath
of an already-built executable.
Another option is running your executable with LD_LIBRARY_PATH
set so that the shared library is on the load path. You could also install the shared library system wide if appropriate. A final option is to load the library manually when your application boots using dlopen
.
The correct choice depends on how you will distribute this and to who you will distribute this, if at all. Keep in mind if you use rpath
/dllpath
the end user is unlikely to have protobuf
installed in the same location you do.