Why is Xcode 4 Preview 5 not resolving the crget() function when I include <sys/ucred.h>?
I am experimenting with the Mac OS X 10.6.5 kernel libraries. Specifically, I am attempting to do a very simple call to the crget() function (please see: http://fxr.watson.org/fxr/source/sys/ucred.h?v=DFBSD#L101 for function prototype).
The code is only:
#include <sys/param.h>
#include <sys/ucred.h>
// Main().
int main (void) {
// Return a u开发者_高级运维cred struct from kernel for this process.
struct ucred *processCredentials = crget();
// Rest of code...
return 0;
}
XCode reports:
Undefined symbols for architecture i386: "_crget", referenced from: _main in main.o ld: symbol(s) not found for architecture i386
Can someone please tell me what I'm missing ?
Thanks,
Scott
From the documentation:
Note: Functions for working with basic user credential [sic] are not exported outside of the kernel, and thus are not generally available to kernel extensions.
So unless you're modifying the kernel proper, or using what may amount to an atrocious hack, you can't link against them.
精彩评论