Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ben.Key

macrumors newbie
Original poster
May 29, 2011
3
0
Hello,

I have a question about using SecKeychainAddGenericPassword and related functions in the Keychain Services API. I am attempting to build the example programs provided on the Keychain Services Tasks for Mac OS X web page but I am getting several linker errors due to undefined symbols including CFRelease, SecKeychainItemFreeContent, SecKeychainFindGenericPassword, SecKeychainItemModifyAttributesAndData, and SecKeychainAddGenericPassword. What library do I need to link to in order to resolve these errors? The Keychain Services Tasks for Mac OS X and Keychain Services Reference web pages do not appear to provide an answer to this question.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
CFRelease is CoreFoundation.framework. The others are in Security.framework, I think. I'm away from my beloved Mac so can't confirm this.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
First hit searching for SecKeychainAddGenericPassword site:developer.apple.com is this:
http://developer.apple.com/library/...nce/keychainservices/Reference/reference.html

Top of the page says:
Framework Security/Security.h

There's a link embedded on the first word Security, leads to this:
http://developer.apple.com/library/...ce/_index.html#//apple_ref/doc/uid/TP40004330


Nice one chown33. I'd never acknowledged there was link there. I'd always just gone with the convention to determine which framework I was dealing with.
 

Ben.Key

macrumors newbie
Original poster
May 29, 2011
3
0
Need more information on using SecKeychainAddGenericPassword

Hello,

I would like to thank jiminaus and chown33 for their quick replies. But I am not certain how to link against the Security.framework.

I am not using XCode. I am attempting to build using Make because that is what I am familiar with and that is what a project my code will eventually need to go into uses and I am not certain what linker option to use to tell it to link against the Security.framework.

I tried -lSecurity.framework, -lSecurity, -lsecurity, and -lsecurity.framework and I get library not found errors. I am compiling using GCC.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
Hello,

I would like to thank jiminaus and chown33 for their quick replies. But I am not certain how to link against the Security.framework.

I am not using XCode. I am attempting to build using Make because that is what I am familiar with and that is what a project my code will eventually need to go into uses and I am not certain what linker option to use to tell it to link against the Security.framework.

I tried -lSecurity.framework, -lSecurity, -lsecurity, and -lsecurity.framework and I get library not found errors. I am compiling using GCC.

Use the -framework option to gcc to compile against and link to a framework. For example.

Code:
gcc -framework CoreFramework -framework Security -o sectest sectest.c

Note that you don't need set include paths or lib paths. A framework is directory containing the dynamic lib library (.dylib file) for linking and running, header files for compiling, documentation for coding, and any resource files need by the library during runtime. So the -framework will do the work of -I, -L and -l.

The other Apple specific gcc flag you might be interested in is -arch. -arch i386 will compile 32-bit Intel code. -arch x86_64 will compile 64-bit Intel code. -arch ppc will compile PowerPC code. If you include multiple -arch options, you'll get a universal binary.
 

Ben.Key

macrumors newbie
Original poster
May 29, 2011
3
0
Thanks

Hello,

I posted a message saying I figured it out and that the linker option is -framework. Then I noticed a reply from jiminaus telling me the same thing.

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.