I want to update a library with new symbols (ie partial recompilation):

libmylib.so : compiled from bar.d and foo.d

now update the file foo.d

dmd -c -fPIC foo.d -offoo.o

clang++ -o libmylib_update.so foo.o -shared -Wl,-lmylib

When trying to dlopen libmylib_update.so from C++ it fails with:
The module 'foo' is already defined in 'libmylib.so'

(it somehow works when the dlopen is called from D)

How would I achieve that?