delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/09/20/05:12:58

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Andrew Schulman <schulman DOT andrew AT epamail DOT epa DOT gov>
Subject: compilation fails with Win32 API call
Date: Tue, 20 Sep 2011 05:12:07 -0400
Lines: 21
Message-ID: <bilg77dmpjm2d0bcu3tiqcl2i4cau04lqo@4ax.com>
Mime-Version: 1.0
X-Archive: encrypt
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019