www.delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT sources DOT redhat DOT com |
Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
Date: | Thu, 5 Jul 2001 22:20:43 -0700 (PDT) |
From: | Mo DeJong <mdejong AT cygnus DOT com> |
To: | cygwin AT sources DOT redhat DOT com |
Subject: | Problem choosing exe entry point. |
Message-ID: | <Pine.SOL.3.91.1010705215806.2695B-100000@cse.cygnus.com> |
MIME-Version: | 1.0 |
Hi all. I think I have found a problem with the way Cygwin ld picks the executable entry point when both WinMain() and main() are available. I would think that passing in the -mwindows flag (which gets passed to ld as --subsystem windows) would clear things up and link with WinMain(). Instead, Cygwin ld is choosing main(). Here is a quick example to demonstrate the problem: % cat t2.c #include <windows.h> #include <winbase.h> #include <winuser.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { return 1; } int main() { return 0; } /* End of t2.c */ Compiled with VC++: % cl -c t2.c -MD % link /Out:t2 t2.obj -subsystem:windows msvcrt.lib % ./t2.exe % echo $? 1 (The above uses WinMain() as the entry point, as expected) Compiled with Cygwin gcc. % gcc -mwin32 -c t2.c % gcc -mwindows -o t2 t2.o /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-2/../../../../i686-pc-cygwin/bin/ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000 % ./t2.exe % echo $? 0 (Note how main() was used as the entry point above) The workaround is to explicitly pass in the WinMain() entry point: % gcc -mwindows -o t2 t2.o -e _WinMain AT 16 % ./t2.exe % echo $? 1 Does this seem like a bug in ld to anyone else? I would think that passing "--subsystem windows" should make it default to WinMain() while passing "--subsystem console" would make it default to main(). Does that seem reasonable? Mo DeJong Red Hat Inc -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |