Re: Calling functions from libraries within libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16 February 2012 14:55, Jonathan Wakely wrote:
> On 16 February 2012 12:55, HvW wrote:
>>
>> 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.
>>
>> Any comments, suggestions or explanations will be appreciated.
>
> The answer depends what platform you're using which you didn't say,
> and isn't really a GCC question, it's about the linker.  You also
> haven't shown your linker commands or the actual error messages you're
> getting, which prevents anyone giving an accurate answer.
>
> For GNU/Linux if you link Lib_AppCfg to Lib_Crc it should have a
> DT_NEEDED tag, which will cause the dynamic linker to load Lib_Crc
> when starting the application.

On some recent GNU/Linux systems you might also need to use
--copy-dt-needed-entries when linking your application, to cause the
linker to look in Lib_AppCfg's library dependencies for the unresolved
symbols.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux