Does program need additional symbols from .so shared library except those declared in header file?
Posted
by solotim
on Stack Overflow
See other posts from Stack Overflow
or by solotim
Published on 2010-03-03T08:48:02Z
Indexed on
2010/03/14
23:59 UTC
Read the original article
Hit count: 211
In C programming, I thought that a object file can be successfully linked with a .so file as long as the .so file offers all symbols which have been declared in the header file.
Suppose I have foo.c, bar.h and two libraries libbar.so.1 and libbar.so.2. The implementation of libbar.so.1 and libbar.so.2 is totally different, but I think it's OK as long as they both offers functions declared in bar.h.
I linked foo.o with libbar.so.1 and produced an executable: foo.bin. This executable worked when libbar.so.1 is in LD_LIBRARY_PATH.(of course a symbolic link is made as libbar.so) However, when I change the symbolic link to libbar.so.2, foo.bin could not run and complainted this:
undefined symbol: _ZSt4cerr
I found this symbol type is 'B' and it does not appear in libbar.so.2. Obviously this symbol has nothing to do with those functions I decared in bar.h. What's wrong here?
© Stack Overflow or respective owner