views:

79

answers:

2

Hi All,

I am trying to suspend my system using a c++ program using SetSuspendState method but I am facing issue during linking.

I am using g++-4 (GCC) 4.3.4 20090804 (release) 1 compiler on Windows 7 OS (64bit).

The code I have written is

#include <iostream>
#include "windows.h"
#include "powrprof.h"

using namespace std;

int main() {

    cout << SetSuspendState(false, true, false);
    return 0;
}

Following is the error I am facing:

/cygdrive/c/Users/Vikas/AppData/Local/Temp/ccFpLgPi.o:suspend.cpp:(.text+0xa4): undefined reference to `_SetSuspendState@12' collect2: ld returned 1 exit status

Kindly help me in resolving this issue.

Thanks in advance ...

+2  A: 

As msdn says you need to link PowrProf.lib.

Andreas Bonini
+1 -- Pedantic: Well, linked to, not included.
Billy ONeal
I guess it is bundled only along with VC++. I tried to search powerprof.lib it for download but was unsuccessful.
vcosk
On MinGW, it should be something like libpowerprof.a. That's why I prefer to compile with VC++ on Windows and g++ on Linux, there are much less problems with documentation using "standard" compilers and SDKs.
Matteo Italia
+3  A: 

I believe dlltool can be used to create import libraries from DLLs for use with GCC under Cygwin. The DLL exporting the functions pwrprof.dll should be located in your Windows system directory somewhere.

Richard Cook