9

有人可以帮我纠正一下吗?我正在使用链接,-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;
}
4

1 回答 1

8

您需要链接到CoreFoundation.framework,这是您在第一行代码中包含的内容。(CF代表___CFConstantStringClassReferenceCoreFoundation kCFBooleanTrue)。

于 2012-12-24T01:25:06.010 回答