library path when dynamically loaded?

The dynamic linker actually searches several places to find each dynamic library. These include (from man ld.so): Paths given by the environment variable LD_LIBRARY_PATH Paths baked into the binary load the library under the DT_RUNPATH entry The cache file /etc/ld.so.cache /lib and /usr/lib If you want to get the path for a specific shared library, … 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

how to call function in executable from my library?

In Linux/ELF you can pass the -export-dynamic option to the linker (-rdynamic on the compiler driver gcc) so symbols from the executable are exported to shared objects. You’d have a dummy print implementation in your library, which would be shadowed by the implementation on your executable, since the executable is usually searched before shared objects … Read more