Search code examples
ocamlprotobuf-comake

Telling omake to use static version of a c library


I'm using omake to build a native binary executable. After it links and i try to run it, it fails to run giving the following error:

error while loading shared libraries: libprotobuf-c.so.1: cannot open shared object file: No such file or directory

Is there a way, at compile time, to tell the executable to pick up the static version: libprotobuf-c.a and not the shared on?


Solution

  • There doesn't seem to be a global flag that can be passed to ld, the linker, that enforces the linker prefer static libraries to dynamic ones when available. In my case, I set the library name explicitly like so:

    OCAML_LINK_FLAGS += -cclib -l:libprotobuf-c.a