Re: Problems with shared library using static objects

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

 



Jorge Pereira wrote:
> Hello Everyone!
>
> when compile the dynamic project and have duplicate calls for some
> libraries, eg:
>
> gcc -shared -o libfoo.so /path/libhehe.so /path/libhehe.so /path/libhehe.so
>
> This works fine! but when have static files, don't works becouse the
> gcc talks about "redefinitions" of libraries, eg:
>
> gcc -shared -o libfoo.so -Wl,-whole-archive /path/libhehe.a
> /path/libhehe.a /path/libhehe.a
>   
There's a quite good annotation about -whole-archive in the man page of ld:

"Second, don’t  forget  to  use  -Wl,-no-whole-archive  after  your 
list of archives, because gcc will add its own list  of  archives  to 
your link and you may not want this flag to affect those as well."

After specifying -Wl,-no-whole-archive, I would suppose you'll get some
error messages about multiple definitions, if your libraries contain
overlapping definitions (e.g. of functions). To my opinion, you should
try to avoid multiple definitions of the same symbol, but nevertheless
there's a linker option to allow multiple definitions:

--allow-multiple-definition (-z muldefs)
           Normally when a symbol is defined multiple times, the linker
will report a fatal error. These options allow multiple definitions and
the first definition will be used.

Andi

> My doubt is: exist some way for gcc ignore the multiple references!?
> Thanks!
> --
> Regards,
> +--------------------------------------------+
> Jorge Pereira,
> Blog: http://blog.jorgepereira.com.br/
> +--------------------------------------------+
>
>   


[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