【发布时间】:2016-11-02 08:15:06
【问题描述】:
我需要在睡眠和唤醒 Mac OS 时在我的 C++ 应用程序中执行一些操作。有人指出我要使用 I/O Kit。
我关注了this guide,特别是“清单 3”。 IOKit 的 #include 指令没有发生构建错误。
但是,当我取消注释 IOAllowPowerChange() 或 IOCancelPowerChange() 时,构建失败:
Undefined symbols for architecture x86_64:
"_IOAllowPowerChange", referenced from:
SleepCallback(void*, unsigned int, unsigned int, void*) in MyAppFrameWork.a(PowerWatcher.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试在 Project Settings > Build Phases > Link Binary With Libraries 中添加 IOKit.framework,但这并没有改变任何内容。
我错过了什么?
编辑
使用 I/O Kit 中的任何方法都会出现同样的错误,包括:IONotificationPortGetRunLoopSource() 和 IORegisterForSystemPower()。
在声明变量时没有错误,例如IONotificationPortRef
【问题讨论】:
标签: c++ xcode macos build iokit