Ok, I am pretty sure this is a bug in the dynamic linker, but I'll post here anyway to see, if someone has a straightforward explanation of the phenomenon.
Short store: You take libjpeg.so (which is, apparently, a c only lib). You then create a c++ file referencing it, remembering to #include
If you reference jpeg in the main c++ file, there are no problems.
This problem seems to only occur when mixing c and c++ shared objects in a way, so the c objects are subordinate to the c++ objects. Solution??
See my full project here (just run "make" on it):
https://dl.dropboxusercontent.com/u/5482530/Code%20examples/jpeg_error.lha
EDIT: Ok, apparently this problem only arise with some shared objects. Tried:
libjpeg.so FAIL
libpng.so FAIL
libz.so WORKS
homemade.so WORKS
So something must be fishy with libjpeg.so and libpng.so. Objdump shows, that all the symbol names are preceded by a library version string, as contrary to libz... Could that be an issue...?
Probably the header files are missing:
around the function prototypes.
You can workaround it in your own code by adding it around the include statement like so:
No, the extern "C" statement doesn't change the outcome (it is present in the header file). Thomas Frieden explained the problem to me, and it has to do with versioned symbols. If I do objdumt -T libjpeg.so, I can see, that the symbols are prefixed with 'LIBJPEG_9.0'. The same for libpng. libz.so doesn't have those. The problem is in elf.library, and will hopefully be properly fixed at some point. Until then I have had to create my own libjpeg.so with no versioned symbols, that seems to have temporarily solved the problem.
You are correct. A fix for elf.library is needed to avoid this problem completely.