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;
}
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With