Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 29, 2011, 09:39 PM   #1
Ben.Key
macrumors newbie
 
Join Date: May 2011
Using SecKeychainAddGenericPassword

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.
Ben.Key is offline   0 Reply With Quote
Old May 29, 2011, 10:30 PM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: 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 is offline   0 Reply With Quote
Old May 30, 2011, 12:21 AM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
First hit searching for SecKeychainAddGenericPassword site:developer.apple.com is this:
http://developer.apple.com/library/m...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/m...uid/TP40004330
chown33 is offline   0 Reply With Quote
Old May 30, 2011, 01:14 AM   #4
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by chown33 View Post
First hit searching for SecKeychainAddGenericPassword site:developer.apple.com is this:
http://developer.apple.com/library/m...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/m...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.
jiminaus is offline   0 Reply With Quote
Old May 30, 2011, 02:11 AM   #5
Ben.Key
Thread Starter
macrumors newbie
 
Join Date: May 2011
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.
Ben.Key is offline   0 Reply With Quote
Old May 30, 2011, 02:46 AM   #6
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by Ben.Key View Post
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.
jiminaus is offline   0 Reply With Quote
Old May 30, 2011, 03:38 AM   #7
Ben.Key
Thread Starter
macrumors newbie
 
Join Date: May 2011
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!
Ben.Key is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump

All times are GMT -5. The time now is 04:40 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC