X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-0.3 required=5.0	tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_NUMERIC_HELO,RP_MATCHES_RCVD,SPF_HELO_PASS,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: jojelino <jojelino@gmail.com>
Subject: Re: compilation fails with Win32 API call
Date: Tue, 20 Sep 2011 19:15:25 +0900
Lines: 33
Message-ID: <j59p3e$kaf$1@dough.gmane.org>
References: <bilg77dmpjm2d0bcu3tiqcl2i4cau04lqo@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:8.0a2) Gecko/20110919 Thunderbird/8.0a2
In-Reply-To: <bilg77dmpjm2d0bcu3tiqcl2i4cau04lqo@4ax.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On 2011-09-20 PM 6: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
here you are.
http://msdn.microsoft.com/en-us/library/aa383745.aspx
> [2]
> http://www.cygwin.com/faq/faq.programming.html#faq.programming.win32-api
>
>
please define WINVER so that you can get definition what you want
(gcc -E -DWINVER=0x500 - <<EOF
#include <windows.h>
EOF
)|grep SetThreadExecution

now you can see SetThreadExecutionState is defined


--
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

