I am trying to compile D code to a shared library to be called by another language (in this case Julia). I can get a basic call to work but I can't call functions that use Phobos (I have no idea how to compile against it). I have found some documentation here and here that lists compilation against specific flags so for instance I have tried:
ldc2 jbasic.d -O3 -link-defaultlib-shared --betterC --boundscheck=off -nogc -shared -of=jbasic.so
But in Julia (and the equivalent thing happens in R), when I attempt to load the function I get an error:
ERROR: could not load library "./jbasic.so" ./jbasic.so: undefined symbol: _D3std6random__T21MersenneTwisterEngineTmVmi64Vmi312Vmi156Vmi31VmN5403634167711393303Vmi29Vmi6148914691236517205Vmi17Vmi8202884508482404352Vmi37VmN2270628950310912Vmi43Vmi6364136223846793005ZQGt6__initZ
I tried the equivalent with
dmd jbasic.d -O -defaultlib=libphobos2.so -betterC -fPIC -boundscheck=off -shared -of=jbasic.so
with the same result.