This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compilation fails with Win32 API call


On 9/20/2011 17:12, Andrew Schulman wrote:
> I'm trying to compile a program that calls the win32 function
> SetThreadExecutionState, in kernel32.dll [1].  The link step fails:
> 
> $ gcc -c nosleep.c
> $ gcc -o nosleep nosleep.o -lkernel32
> nosleep.o:nosleep.c:(.text+0x1f): undefined reference to
> `_SetThreadExecutionState'
> nosleep.o:nosleep.c:(.text+0x5c): undefined reference to
> `_SetThreadExecutionState'
> collect2: ld returned 1 exit status
> 
> According to the FAQ [2], I shouldn't even have to include -lkernel32.
> 
> Can someone please tell me what I'm doing wrong?
> 
> Thanks,
> Andrew.
> 
> [1] http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx
> [2]
> http://www.cygwin.com/faq/faq.programming.html#faq.programming.win32-api
> 
> 

Hi,

There are a few possible causes.

1) You didn't include windows.h
2) You included it but didn't bump _WIN32_WINNT or equivalent.
3) The declaration is missing from winbase.h


Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]