Subject: RE: WinMainCRTStartup again
From: [email-masked] (Colin Peters)

24 Jan 1997 12:08:53 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BC0A17.57250220.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "[email-masked]'"
	 <[email-masked]>
Original-Cc: "[email-masked]" <[email-masked]>,
        "[email-masked]" <[email-masked]>
Original-Sender: [email-masked]

[email-masked] 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 - [email-masked]
-- 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
"[email-masked]" with one line of text: "help".