delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/11/18/20:43:07

From: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters)
Subject: RE: Petzold Example
18 Nov 1997 20:43:07 -0800 :
Message-ID: <01BCF4E6.C584C740.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
To: "'GBradfor'" <GBradfor AT fhssmtp DOT redstone DOT army DOT mil>
Cc: "'GNU-Win32'" <gnu-win32 AT cygnus DOT com>

GBradfor wrote:
>     the following two-step compile:
>     
>        gcc -c -DSTRICT -o hellowin.obj hellowin.c
>        ld -o hellowin.exe hellowin.obj --subsystem windows -luser32 /
>                -lgdi32 -L$(GCC_WIN_LIB)
>     
>     After copying mmsystem.h down from Microsoft's web, Everything 
>     compiled and linked.  I do get this warning, however:
>     
>        ld: warning: cannot find entry symbol WinMainCRTStartup; defaulting
>                to 00401000
>     
>     Using the "-e mainCRTStartup" as suggested in another post doesn't 
>     help; the linker can't find that symbol, either.
>     
>     When I try to run the resulting executable, I get the following error 
>     message:
>     
>        A required .DLL file, j.DLL, was not found.

This message indicates, usually, that the list of DLLs to import is corrupt.
And this happens when the dll import list is not properly terminated by
a little piece of code in crt0.o. (NOTE: crt0.o is also the place where the
entry point mainCRTStartup is defined, which is another hint.)

Basically the problem is that you are running ld directly. Generally it is
a better idea to let gcc call the linker by running gcc as if it *was* the
linker. That way all kinds of default options get set, including the linking
of the startup code crt0.o (which you need).

Change this:
>        ld -o hellowin.exe hellowin.obj --subsystem windows -luser32 /
>                -lgdi32 -L$(GCC_WIN_LIB)

to:
    gcc -o hellowin.exe hellowin.o -mwindows

or:
    gcc -o hellowin.exe hellowin.o -Wl,--subsystem,windows -luser32 -lgdi32

And things should work, or at least your bugs will change :)

Good luck,
Colin.

-- Colin Peters - Saga Univ. Dept. of Information Science
-- colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp - finger for PGP public key
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

-
For help on using this list (especially unsubscribing), 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