macos 上这段程序应该链接什么库
#include <iostream>
#include <stdio.h>
#include <CoreServices/CoreServices.h>
int main()
{
CSIdentityQueryRef query = CSIdentityQueryCreateForCurrentUser(kCFAllocatorSystemDefault);
CFErrorRef error;
uint8 qdata[1024] = {0};
if (CSIdentityQueryExecute(query, kCSIdentityQueryGenerateUpdateEvents, &error))
{
CFArrayRef foundIds = CSIdentityQueryCopyResults(query);
if (CFArrayGetCount(foundIds) == 1)
{
CSIdentityRef userId = (CSIdentityRef) CFArrayGetValueAtIndex(foundIds, 0);
CFDataRef data = CSIdentityGetImageData(userId);
CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), qdata);
}
}
CFRelease(query);
}
这段代码是获取当前用户的头像路径。
我用 g++ 编译的时候报错,
ethson@macbookpro:~/Project/cpp_example$ g++ ./example.cpp -o exam
Undefined symbols for architecture x86_64:
"_CFArrayGetCount", referenced from:
_main in example-7e578a.o
"_CFArrayGetValueAtIndex", referenced from:
_main in example-7e578a.o
"_CFDataGetBytes", referenced from:
_main in example-7e578a.o
"_CFDataGetLength", referenced from:
_main in example-7e578a.o
"_CFRelease", referenced from:
_main in example-7e578a.o
"_CSIdentityGetImageData", referenced from:
_main in example-7e578a.o
"_CSIdentityQueryCopyResults", referenced from:
_main in example-7e578a.o
"_CSIdentityQueryCreateForCurrentUser", referenced from:
_main in example-7e578a.o
"_CSIdentityQueryExecute", referenced from:
_main in example-7e578a.o
"_kCFAllocatorSystemDefault", referenced from:
_main in example-7e578a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我猜测是没有链接系统库造成的,但是我查了一圈,也没找到应该链接哪个库,求指教。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)