gnustep-dev
[Top][All Lists]
Advanced

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

Re: Categories within static archives


From: David Chisnall
Subject: Re: Categories within static archives
Date: Tue, 23 Feb 2010 18:47:00 +0000

It sounds like the Objective-C load function is not being called.  This 
shouldn't require any extra linker options; if your library is correctly 
created then the code to call this will be in the constructors section of the 
resulting executable.  The simplest way of testing that they are is to 
implement a +load method on a class in the same file and have it log something, 
or just define a function with __attribute__((constructor)).

On OS X, the procedure is likely to be entirely different because Apple's 
runtimes handles Objective-C initialization code in a completely different way 
to the GNU runtime.  We just require each compilation unit to call an init 
function, they collect everything in global sections and then have the runtime 
look in those sections after relocation.

Note that load order is not defined.  Code in +load methods may execute before 
all categories have been loaded.

David

On 18 Feb 2010, at 22:55, Lewis Mackenzie wrote:

> I'm linking against a static archive which contains custom categories on 
> NSArray and NSString, but the problem I'm finding is that the methods these 
> categories add aren't present at runtime.
> 
> I've done a little bit of research, and found that under OS X, ld has these 
> additional options:
> 
> -all_load   Loads all members of static archive libraries.
> 
> -ObjC       Loads all members of static archive libraries that implement
>            an Objective-C class or category.
> 
> I've tried building under OS X using these options and everything now works 
> correctly - but I need this to work under a linux system using GNUstep, so I 
> wondered if anybody has any experience with doing this, or can suggest any 
> solutions?
> 
> The build environment I'm trying to get it to work under is:
> 
> Debian lenny
> gcc 4.3.2 (debian package)
> gnustep-make-2.2.0 (from source)
> gnustep-base-1.19.3 (from source)
> 
> Lewis
> 
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnustep-dev


-- Sent from my Cray X1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]