有人可以請我正確的。我使用-lIOKit
進行鏈接,但顯然還需要另一個庫。要鏈接哪個庫(OSX)
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;
}
「架構x86_64的未定義符號」可能意味着您只有32位版本的庫。如果使用'-m32'構建,那就是了。 –
不,同樣的錯誤,但從x86_64更改爲i386 –
啊,值得一試。我很抱歉,但我無法幫助你,不知道可可(這是Mac,不是嗎?)。 –