Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 To: cygwin AT sources DOT redhat DOT com Subject: Problem choosing exe entry point. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 #include #include 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/