<div dir="ltr">I've managed to compile the ncurses example with the following commands:<div><br></div><div><div>ncurses_cmd.native: <a href="http://ncurses.ml">ncurses.ml</a> ncurses.mli <a href="http://ncurses_cmd.ml">ncurses_cmd.ml</a></div>

<div><span class="" style="white-space:pre">    </span>ocamlfind ocamlc -c -g -annot -package unix,threads,bigarray -thread -o ncurses.cmi ncurses.mli</div><div><span class="" style="white-space:pre">    </span>ocamlfind ocamlopt -c -g -annot -package unix,threads,bigarray,ctypes,ctypes.foreign -thread -o ncurses.cmx <a href="http://ncurses.ml">ncurses.ml</a></div>

<div><span class="" style="white-space:pre">    </span>ocamlfind ocamlopt -a -cclib -lncurses ncurses.cmx -o ncurses.cmxa</div><div><span class="" style="white-space:pre"> </span>ocamlfind ocamlopt -c -g -annot -package unix,threads,bigarray -thread -o ncurses_cmd.cmx <a href="http://ncurses_cmd.ml">ncurses_cmd.ml</a></div>

<div><span class="" style="white-space:pre">    </span>ocamlfind ocamlopt -g -linkpkg -package unix,threads,bigarray,ctypes,ctypes.foreign -thread ncurses.cmxa ncurses_cmd.cmx -o ncurses_cmd.native</div></div><div><br></div>

<div><br></div><div>Now, I'm trying to mimic this to wrap a library that is not in my system's default location. A couple of questions:</div><div><br></div><div>* What is the recommended way to package this? Should I include the source of the external C library within my OCaml repo?</div>

<div><br></div><div>* What options do I have to use to link in a library in a custom location? I've tried every variation of -cclib, -ccopt -L/path/to/lib, -linkall, and am just guessing at this point. No matter what, I always get this error:</div>

<div><br></div><div><div>Fatal error: exception Dl.DL_error("dlsym(RTLD_DEFAULT, sam_open): symbol not found")</div><div>Raised at file "src/<a href="http://dl.ml">dl.ml</a>", line 42, characters 26-44</div>

<div>Called from file "src/<a href="http://foreign.ml">foreign.ml</a>", line 18, characters 25-53</div><div>Called from file "<a href="http://samtools.ml">samtools.ml</a>", line 4, characters 15-60</div>

</div><div><br></div><div>However, I'm pretty sure "sam_open" is exported by the library I'm using:</div><div><br></div><div><div>$ nm libbam.a | grep sam_open</div><div>0000000000000060 T _sam_open</div>

<div>0000000000005cf0 S _sam_open.eh</div><div>                 U _sam_open</div><div>                 U _sam_open</div><div>                 U _sam_open</div><div>                 U _sam_open</div></div><div><br></div></div>