Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which library to link (OSX)

Can someone put me right please. I'm linking using -lIOKit but clearly need another library too.

Undefined symbols for architecture x86_64:
  "___CFConstantStringClassReference", referenced from:
      CFString in code-9daAw9.o
  "_kCFBooleanTrue", referenced from:
      _dimDisplayNow in code-9daAw9.o

Here is the code (found at 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;
}
like image 273
William Morris Avatar asked Dec 24 '12 00:12

William Morris


1 Answers

You need to link against the CoreFoundation.framework, which is what you've included on the first line of code. (The CF in ___CFConstantStringClassReference and kCFBooleanTrue stand for CoreFoundation).

like image 193
NSGod Avatar answered Oct 04 '22 06:10

NSGod