Multiple instances of singleton across shared libraries on Linux

First, you should generally use -fPIC flag when building shared libraries. Not using it “works” on 32-bit Linux, but would fail on 64-bit one with an error similar to: /usr/bin/ld: /tmp/ccUUrz9c.o: relocation R_X86_64_32 against `.rodata’ can not be used when making a shared object; recompile with -fPIC Second, your program will work as you expect … Read more

dlopen from memory?

I needed a solution to this because I have a scriptable system that has no filesystem (using blobs from a database) and needs to load binary plugins to support some scripts. This is the solution I came up with which works on FreeBSD but may not be portable. void *dlblob(const void *blob, size_t len) { … Read more