我正在尝试使用Clang在macOS上构建C ++应用程序。我正在使用CoreAudio API,因此需要链接CoreServices框架。但是,出现以下错误:
铛:错误:未知参数:'-framework CoreServices'
这是我的Clang版本:
clang --version
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /usr/local/bin
这些是我的链接器标志:
-framework CoreServices
我在这里做错了什么?
以下程序代码打印出输出设备占用的大小(这仅仅是为了使用CoreAudio API的某些功能):
// main.cpp
#include <cstdlib>
#include <cstdio>
#include <CoreAudio/CoreAudio.h>
#include <CoreServices/CoreServices.h>
int
main (void)
{
AudioObjectPropertyAddress property = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
OSStatus status;
UInt32 size;
status = AudioObjectGetPropertyDataSize(
kAudioObjectSystemObject,
&property,
0,
NULL,
&size);
printf("status(%d), size: %d\n", status, size);
return EXIT_SUCCESS;
}
此C ++程序可使用以下命令进行编译:
clang -framework CoreServices -framework CoreAudio main.cpp
并生成一个a.out
可执行文件,然后您可以使用
./a.out
> status(0), siz
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句