I think this might help: $ dmd -defaultlib=libphobos2.so main.d
El 10/10/26 a les 16:52, Rambutan via Digitalmars-d-learn ha escrit: > I've been using a D to dynamically load a dynamic library itself also written > in D as a part of a much bigger project on Linux. > > I've been using gdc where the difficulties I am about to describe do not > exist. > gdc D version 2.108 > gdc (GCC) 14.2.1 20250405 > > I used the functions in core.sys.posix.dlfcn with the exception that I am > using core.runtime.Runtime.loadLibrary instead of core.sys.posix.dlfcn.dlopen > and I am using core.runtime.Runtime.unloadLibrary instead of > core.sys.posix.dlfcn.dlclose because the D runtime in the dynamic library > needs to be integrated with that of the loading program on load and separated > and shut down on unload. > > https://dlang.org/phobos/core_runtime.html#.Runtime.loadLibrary > > When I try to compile the same source using dmd, I get a linkage problem. > What do I need to do to bring these functions in? > ``` > /usr/bin/ld: dyload.o: in function > `core.runtime.Runtime.loadLibrary!().loadLibrary(scope const(char[]))': > main.d:(.text._D4core7runtime7Runtime__T11loadLibraryZQoFMxAaZPv[_D4core7runtime7Runtime__T11loadLibraryZQoFMxAaZPv]+0x96): > undefined reference to `rt_loadLibrary' > /usr/bin/ld: dyload.o: in function > `core.runtime.Runtime.unloadLibrary!().unloadLibrary(void*)': > main.d:(.text._D4core7runtime7Runtime__T13unloadLibraryZQqFPvZb[_D4core7runtime7Runtime__T13unloadLibraryZQqFPvZb]+0x5): > undefined reference to `rt_unloadLibrary' > collect2: error: ld returned 1 exit status > Error: linker exited with status 1 > ``` > > > > >
