delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/24/12:08:53

From: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters)
Subject: RE: WinMainCRTStartup again
24 Jan 1997 12:08:53 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <01BC0A17.57250220.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Original-To: "'dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de'"
<dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de>
Original-Cc: "benfante AT dafne DOT dei DOT unipd DOT it" <benfante AT dafne DOT dei DOT unipd DOT it>,
"gnu-win32 AT cygnus DOT com" <gnu-win32 AT cygnus DOT com>
Original-Sender: owner-gnu-win32 AT cygnus DOT com

dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de wrote:
>: gcc -o hellowin.exe hellowin.o -luser32 -lgdi32 -Wl,--subsystem,windows
>: /cygnus/H-i386-cygwin32/bin/ld.exe: warning: cannot find entry symbol
>:   _WinMainCRTStartup; defaulting to 00401000
>
>Just try as you would under unix:
> gcc -o hellowin.exe hellowin.o
>Telling the beast that it really is Windows seems to make it angry 8-) 

The original poster is compiling a GUI program. If they follow your
suggestion they will have no warnings and will get a working executable,
however it will be marked internally as a console application resulting
in the following undesirable behavior:

 - If run from the command line the program will "take over" the console
   and not return a prompt until exited (this differs from the usual
   GUI program, e.g., notepad).

 - If run using "start" or from an icon (or otherwise not from a console
   window) an extra console window will appear for the duration of the
   program's execution.

On the other hand that warning is not dangerous in the vast majority of
cases. It seems that the people at Cygnus were preparing to do some
different startup code for GUI vs. console apps (probably calling WinMain
instead of main), so they made the linker look for different entry points
based on the subsystem. However, the crt0 and library code does not
support this difference yet, so everything goes through _MainCRTStartup
defined in crt0.o. Luckily (or rather, by design) _MainCRTStartup ends up
in the correct place in the executable.

You can still use main or WinMain because if there's no main in your
object files a main in the cygwin library (or mingw32 library if you use
the Minimalist GNU Win32) gets used instead, and that calls WinMain
(which is why if you don't have either it says it can't find WinMain).

Ignore the warning and you will get a perfectly functional executable and
no strange console window. As far as I know there is no reason right now
to be concerned about this warning. (Any other bugs are probably not
related to it.)

Colin.

-- Colin Peters - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp
-- Saga University Dept. of Information Science
-- Fundamentals of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/home.html

-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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