有人可以帮我纠正一下吗?我正在使用链接,-lIOKit
但显然也需要另一个库。
Undefined symbols for architecture x86_64:
"___CFConstantStringClassReference", referenced from:
CFString in code-9daAw9.o
"_kCFBooleanTrue", referenced from:
_dimDisplayNow in code-9daAw9.o
这是代码(可在http://www.cocoabuilder.com/archive/cocoa/191807-sleep-display.html找到)
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
static int dimDisplayNow(void)
{
io_registry_entry_t r =
IORegistryEntryFromPath(kIOMasterPortDefault,
"IOService:/IOResources/IODisplayWrangler");
if(!r) return 1;
int err = IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"),
kCFBooleanTrue);
IOObjectRelease(r);
return err;
}
int main(int argc, char **argv)
{
dimDisplayNow();
return 0;
}