Subject: RE: Linking for GUI's
From: [email-masked] (Colin Peters)

10 Jul 1997 23:41:22 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BC8DE7.EFA41140.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "'GNU-Win32'" <[email-masked]>
Original-Sender: [email-masked]

Not much return mail is going to get to you with this address
                   vvvvvvvvvvvvvvvvvvvvvv
nicole nowell[SMTP:[email-masked]] wrote:
>Hi all, I have a very simple question that I can't seem to find on the
>archives or the FAQ.  I am trying to learn win32 programming with the
>Nuts and Bolts Book by Schildt.  Whenever I try to build the first
>example it compiles fine, but the linker cannot resolve any of the Win32
>Api functions.  The faq only says the most common functions are linked
>and you may need to link other libraries.  What libraries should I add
>to the gcc line to build GUI apps (I have successfully compiled several
>simple standard C and C++ programs with mains but no WinMain into
>console apps).

Under Cygnus GNU-Win32 you have to use the -mwindows option to compile
GUI applications, and that will include user32 and gdi32 (as well as
kernel32, which is always included). The Minimalist GNU-Win32 has
similar behavior when the -windows flag is used. You can also
manually link in these two libraries like so:

gcc -o foo.exe foo.o bar.o -luser32 -lgdi32 -Wl,--subsystem,windows

This should compile a GUI program and the two extra libraries will
resolve most of the calls made by a standard Windows program. More
unusual functions are grouped into one of the many libxxx.a import
libraries for the Win32 API (I can't remember which directory they're
in, but it's the same one as libkernel32.a, libuser32.a and libgdi32.a).
Although it is unpleasant, you can use nm and grep to search for
functions which you can't locate:

 nm libxxx.a | grep FunctionName

Will display a match for an import library generally only if the given
function is located in the library.

Anyway, that's a start, good luck.

Colin.

-- Colin Peters - Saga Univ. Dept. of Information Science
-- [email-masked] - 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
"[email-masked]" with one line of text: "help".