Dune project with a C/C++ ctypes foreign defined function

ctypes-foreign looks up the symbol dynamically, and by default it looks in the current executable.

You can make it search in another location instead by passing the optional from argument to foreign, e.g.:

let lib = Dl.dlopen ~filename:"_build/default/lib/dllcpptest_stubs.so"
            ~flags:Dl.[RTLD_NOW; RTLD_GLOBAL]

let fib = foreign "fib" (int @-> returning int)
            ~from:lib

In the long term it might be easier to switch to the stub-generation interface so that symbols are resolved statically.