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

Resolving circular dependencies by linking the same library twice?

The problem with g++ -o myApp -lfoo -lbar -lfoo is that there is no guarantee, that two passes over libfoo and one pass over libbar are enough. The approach with Wl,–start-group … -Wl,–end-group is better, because more robust. Consider the following scenario (all symbols are in different object-files): myApp needs symbol fooA defined in libfoo. … Read more

Linker performance related to swap space?

I am able to reproduce this on an Ubuntu 10.10 system (GNU ld (GNU Binutils for Ubuntu) 2.20.51-system.20100908), and I think I have your answer. First, some methodology. After confirming this happens to me in a small VM (512MB ram, 2GB swap), from here I decided the easiest thing to do would be to strace … Read more

How to force gcc to link an unused static library

Use –whole-archive linker option. Libraries that come after it in the command line will not have unreferenced symbols discarded. You can resume normal linking behaviour by adding –no-whole-archive after these libraries. In your example, the command will be: g++ -o program main.o -Wl,–whole-archive /path/to/libmylib.a In general, it will be: g++ -o program main.o \ -Wl,–whole-archive … Read more

Why does ld need -rpath-link when linking an executable against a so that needs another so?

Why is it, that ld MUST be able to locate liba.so when linking test? Because to me it doesn’t seem like ld is doing much else than confirming liba.so‘s existence. For instance, running readelf –dynamic ./test only lists libb.so as needed, so I guess the dynamic linker must discover the libb.so -> liba.so dependency on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)