Hi, I've packaged up some OCaml code with a C shim and made a shared library (a ".so" file) on OSX. It's all working fine! However the build steps I'm using are a bit verbose -- I wonder if anyone knows how to simplify them? I'm building all the objects and then using a custom linker invocation, see below. Notice that I'm tediously listing all the stubs for all my ocamlfind packages-- this seems like it could be simplified somehow. ``` PACKS="cstruct lwt io-page...." WHERE=$(ocamlc -where) cd _build ocamlfind ocamlopt -thread -package "$PACKS" -c ../c_callbacks.ml -o c_callbacks.cmx ocamlfind ocamlopt -thread -linkpkg -package "$PACKS" -output-obj -o camlcode.o c_callbacks.cmx gcc -I ${WHERE} -g -Wall -Wextra -c ../c_shim.c -o c_shim.o gcc -shared camlcode.o c_shim.o -ldl -lm -L ${WHERE} \ $(ocamlfind query cstruct)/cstruct.a \ $(ocamlfind query cstruct)/libcstruct_stubs.a \ $(ocamlfind query io-page)/io_page.a \ $(ocamlfind query io-page)/io_page_unix.a \ $(ocamlfind query io-page)/libio_page_unix_stubs.a \ $(ocamlfind query lwt.unix)/liblwt-unix_stubs.a \ $(ocamlfind query lwt.unix)/lwt-unix.a \ $(ocamlfind query lwt.unix)/lwt.a \ $(ocamlfind query threads)/libthreadsnat.a \ -lasmrun -lbigarray -lunix -o my_shared_library.so ``` I tried following Jeremy's inverted ctypes example here: https://github.com/yallop/ocaml-ctypes-inverted-stubs-example/blob/ff713bc9a9159828b2c3d7e6661f7ba76855e8b7/Makefile#L29 This looks good because it relies on ocamlfind + ocamlopt to do the right thing but unfortunately it fails on my OSX box because it produces a "bundle" (with "-bundle" linker option) rather than a shared library (with a "-shared" linker option): When ocamlopt builds the ctypes-inverted-stubs-example .so it's one of these: ``` $ file _build/libxmlm.so _build/libxmlm.so: Mach-O 64-bit bundle x86_64 ``` which then causes failures which look like ``` ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file '../_build/test/../libxmlm.so' for architecture x86_64 ``` When I do it by hand, I can replace "-bundle" with "-shared" which results in: ``` $ file _build/libxmlm.so _build/libxmlm.so: Mach-O 64-bit dynamically linked shared library x86_64 ``` which then links ok. Any tips greatly appreciated! Thanks, -- Dave Scott