David
David

Reputation: 14404

How to import IOPMLib.h from IO kit?

I am trying to wake a Mac up with the following code,

CFAbsoluteTime currentTime = CFAbsoluteTimeGetCurrent();
CFDateRef wakeFromSleepAt = CFDateCreate(NULL, currentTime + 60);
IOReturn returnCode = IOPMSchedulePowerEvent(wakeFromSleepAt, NULL, CFSTR(kIOPMAutoWakeOrPowerOn));

I'm having trouble finding the right framework/header to import.

I'm using #import <IOKit/pwr_mgt/IOPMLib.h> but the complier still complains. Any suggestions? Thanks.

Edit

I am getting the following error message

Undefined symbols:
  "_IOPMSchedulePowerEvent", referenced from:

Upvotes: 0

Views: 1659

Answers (1)

Aidan Steele
Aidan Steele

Reputation: 11330

What complaint is the compiler giving you? Are you linking against IOKit.framework? If the complaint resembles the following:

Undefined symbols:
"_IOPMSchedulePowerEvent", referenced from:
-[iokittestAppDelegate applicationDidFinishLaunching:] in iokittestAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The above means that you have failed to link against the IOKit framework.

Upvotes: 3

Related Questions