This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling functions from libraries within libraries


16.2.2012 14:55, HvW kirjoitti:

Hi,


I have a library called Lib_Crc to compute the CRC of certain memory areas.
This is used by another library called Lib_Appcfg which performs certain
configuration checking and verification.

My application "Test" needs to use both Lib_Crc functions and Lib_Appcfg
function in order to perform its tasks.

Why do I need to link both Lib_Crc and Lib_Appcfg in my application to use
the Lib_Crc functions? Won't the symbols be available to the application
form the Lib_AppCfg library?

I have tried several linking options including -shared and -export-dynamic
in multiple orders and arrangements, but in all cases when linking is done
on the application, it complains that the Lib_Appcfg says that the Lib_Crc
functions are "undefined references". To fix this I include Lib_Crc in my
app.

If both libs are shared ones, the linker option '--as-needed lib_Crc.so' used when linking the 'lib_Appcfg.so' should put the other to appear as 'NEEDED' inside 'lib_Appcfg.so'. A well-known case about this is the '/lib/libc.so.6' which causes also the 'ld-linux.so.2' (Linux/i386) being automatically searched, from 'objdump -p /lib/libc.so.6' :


Dynamic Section: NEEDED ld-linux.so.2 SONAME libc.so.6 INIT 0x4d495c90 FINI_ARRAY 0x4d6031d4

The option should be this but I'm not sure about how the file name after
it should be given. Could it also be '--as-needed Lib_Crc' for instance.
The file type '.so' is the default type for a shared library...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]