Re: linking an Apple framework into a static lib project and then linking the static lib into an application project...
Re: linking an Apple framework into a static lib project and then linking the static lib into an application project...
- Subject: Re: linking an Apple framework into a static lib project and then linking the static lib into an application project...
- From: Greg Parker <email@hidden>
- Date: Tue, 19 Jul 2011 18:15:08 -0700
On Jul 19, 2011, at 5:11 PM, Glen Haderman wrote:
> I've got a Mac/Cocoa static library project. It links against IOKit.framework. It builds fine.
>
> I take the .a and header and import them into a Mac/Cocoa project.
>
> I get the following linker errors:
>
> Undefined symbols:
> "_IORegistryEntryCreateCFProperty", referenced from:
> +[MyLibrary getThingamajigFromIORegistry] in libMyLibrary.a(MyLibrary.o)
> "_kIOMasterPortDefault", referenced from:
> _kIOMasterPortDefault$non_lazy_ptr in libMyLibrary.a(MyLibrary.o)
> (maybe you meant: _kIOMasterPortDefault$non_lazy_ptr)
> "_IOObjectRelease", referenced from:
> +[MyLibrary getThingamajigFromIORegistry] in libMyLibrary.a(MyLibrary.o)
> "_IORegistryEntryFromPath", referenced from:
> +[MyLibrary getThingamajigFromIORegistry] in libMyLibrary.a(MyLibrary.o)
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
>
> Adding IOKit.framework to the **application** project resolves the problem (obviously), but how can I set everything up so that references to other Apple frameworks which are internal to my static library and linked into the static library... are honored by the linker when building application projects which link against that static library?
You can't.
A static archive is no more than a pile of .o files. They have been compiled and assembled, but not linked. The linker doesn't touch them, and they don't record any dependencies that should be taken into account when they are finally linked.
Your static library project would likely build successfully even if you removed all linked libraries from it.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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