Subject: RE: EGCS-Mingw32 Win32
From: [email-masked] (Colin Peters)

2 Sep 1998 13:20:42 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
To: <[email-masked]>
Cc: "GNU-win32" <[email-masked]>

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