• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting link errors weak-linking against a framework fn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting link errors weak-linking against a framework fn


  • Subject: Getting link errors weak-linking against a framework fn
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 9 Jun 2010 09:04:51 -0700

I’m having trouble weak-linking against a function in a system framework. It was added in 10.6 but I need my code to run on 10.5, so I check whether the function exists before calling it. But even though I weak-import the function, I get a link error.

The function’s not declared in a header*, so I added my own declaration:
extern OSStatus SecKeyCreateWithCSSMKey(const CSSM_KEY *key, SecKeyRef* keyRef) WEAK_IMPORT_ATTRIBUTE;

I call it as follows:
if (SecKeyCreateWithCSSMKey != NULL)
  SecKeyCreateWithCSSMKey(cssmKey,&keyRef);

This works when I build against the 10.6 SDK, but building against 10.5 I get a link error:

Undefined symbols:
"_SecKeyCreateWithCSSMKey", referenced from:
 -[MYSymmetricKey _initWithCSSMKey:] in MYSymmetricKey.o
 _SecKeyCreateWithCSSMKey$non_lazy_ptr in MYSymmetricKey.o
(maybe you meant: _SecKeyCreateWithCSSMKey$non_lazy_ptr)
ld: symbol(s) not found

So am I doing something wrong in my declaration, or is it simply impossible to weak-link with a function that’s newer than the SDK I build against?

—Jens

* Yes, this makes it SPI. Bad developer, no biscuit. However in my defense, (a) there is no real workaround to using this function, and (b) the library it’s in (Security.framework) is open-source so it can’t really be considered “private”. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting link errors weak-linking against a framework fn
      • From: Dave Keck <email@hidden>
    • Re: Getting link errors weak-linking against a framework fn
      • From: Chris Suter <email@hidden>
  • Prev by Date: Re: Xcode 4.0 Confidential Developer Forum is now up
  • Next by Date: Re: Getting link errors weak-linking against a framework fn
  • Previous by thread: PackageMaker woes
  • Next by thread: Re: Getting link errors weak-linking against a framework fn
  • Index(es):
    • Date
    • Thread