delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/09/02/13:20:42

From: colin AT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters)
Subject: RE: EGCS-Mingw32 Win32
2 Sep 1998 13:20:42 -0700 :
Message-ID: <002d01bdd65c$b5392b80$fa173185.cygnus.gnu-win32@gbird0.fu.is.saga-u.ac.jp>
Mime-Version: 1.0
To: <pgarceau AT teleport DOT com>
Cc: "GNU-win32" <gnu-win32 AT cygnus DOT com>

Paul Garceau <pgarceau AT teleport DOT com> wrote:
> Under EGCS-Mingw32, why is it necessary to add a -l reference for
> User32 for a command such as:
>
> gcc test.c -o test.exe
>
>       in order to generate a successful link?


(Assuming test.c uses some functions from the user32 DLL.) This is because
the only Win32 API library included by default in Mingw32 is kernel32 (it's
needed by the startup code). If you are writing a program that uses other
API functions then you need to link in the API libraries explicitly.

Now, if you are writing a GUI program you can use -mwindows and you will
automatically get user32 and a few other basic Win32 API libraries. It was
done this way because GUI programs usually use the Win32 API, so it makes
sense to do the extra library linking. (Note: you can't do "gcc -o test.exe
test.c -mwindows" because the windows option will get sent to the compiler
as well as the linker, and the compiler doesn't understand it, so you have
to compile first and then link with -mwindows.)

I suppose we could just include all those libraries by default all the time,
though I don't think it makes much difference once you understand what's
going on.

Colin.

- Colin Peters - colin at fu.is.saga-u.ac.jp
- http://www.geocities.com/Tokyo/Towers/6162/index.html
- Go not to usenet for counsel, for it will say both
- 'yes' and 'no' and 'try another newsgroup'.


-
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