Re: Mixing Static and Dynamic Librararies, Multiple Definitions of Symbol, Two-Level Namespace
Re: Mixing Static and Dynamic Librararies, Multiple Definitions of Symbol, Two-Level Namespace
- Subject: Re: Mixing Static and Dynamic Librararies, Multiple Definitions of Symbol, Two-Level Namespace
- From: Markus Hanauska <email@hidden>
- Date: Thu, 2 Aug 2007 12:51:56 +0200
I tried that, but that does not solve the problem. I still either get
multiple defined symbol warnings and later on I have two different
symbols in the binary. If I don't define the symbols in the library
at all, it won't compile, not even with bind_at_load.
I found a solution, that works perfectly with 10.4, but I read it
won't work with 10.3... and our software needs to run under 10.3.9,
too. The solution is to define the symbols as weak by prepending them
with
__attribute__((weak))
Symbols that are defined as weak in a library can be overwritten by
symbols with the same name of a binary that is linking against the
library. Even though the symbols are defined as weak everywhere now
(in the static library, hence in the dynamic one, too and also in the
main binary), it looks like after starting the main binary, all
symbols with the same name point to the same memory location, which
is the one of the main binary... exactly what I was looking for.
Too bad it does not work under 10.3.9
BTW, it does not work to not define them as weak and then link the
library with -weak-l<lib> instead of -l<lib>, although the
documantation says, -weak-l links a library in such a way as if all
symbols in the library were defined as weak. But I can't see that it
has any different effect at all, neither on functions nor variables.
If anyone has an idea how we can get such weak symbols for 10.3.9,
too, I'd be very grateful.
On the other hand, I'm not sure if I understand the documantation
correctly. It seems to me that it is 10.4 only, because only GCC 4
supports this attribute, 3.3 did not. Okay, but if the software does
not need to run under 10.2 any longer, there is no need to compile it
with GCC 3.3, in that case one could also use GCC 4, right? GCC 4
binaries created with 10.4 will run under 10.3.9, won't they? (not
under 10.3.x, only 10.3.9 AFAIK). So does the documantation only
refer to the building process or is it that even when building it
with GCC 4, the dynamic linker of 10.3.9 can't support the weak
attribute and will hence ignore it? Has anyone any experience with
new features introduced with GCC 4 and how they work or don't work
under 10.3.9?
Thanks.
On 2007-07-30, at 20:21, Tony Becker wrote:
We had some issues mixing static (3rd party) and dynamic libraries/
frameworks. You might try the following "ld" options:
-ObjC -bind_at_load
and avoid the:
-all_load
option (which was the cause of our multiple symbol warnings)
--
Markus Hanauska
------------------------------------------------------------------------
-----------------------------------
equinux Aktiengesellschaft
Informationstechnologien
Kirschstraße 35
80999 München - Germany
Tel. +49-89-520465-323
Fax +49-89-520465-299
mailto:email@hidden
http://www.equinux.de
------------------------------------------------------------------------
-----------------------------------
Vorstand: Till Schadde (Vors.), Ortwin Gentz - Aufsichtsrat: Stefan
Neuenhahn
USt-IdNr.: DE206360115 - Sitz München - HRB München 129700
------------------------------------------------------------------------
-----------------------------------
equinux USA Inc., San Mateo (CA)
Toll free: 1-888-equinux (1-888-3784689)
http://www.equinux.com
------------------------------------------------------------------------
-----------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden