This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: more information on my problem



From: Kurt H?sler <turtill@ihug.co.nz>
To: gnu-win32@cygnus.com <gnu-win32@cygnus.com>
Date: Thursday, December 18, 1997 12:06 PM
Subject: more information on my problem


>One person suggested explicitly linking libraries in this manner :
>
>gcc -o hello.exe hello.c -lwin32 -Wl,-subsystem,windows
>
>But it says Wl,-subsystem,windows is an undefined flag.  (I cant find it
>anywhere on the docs either)
>
>Someone said adding -lkernal32 -luser32 but the compiler says:
>
>file -lkernal32 not found which looks as though its not recognizing
the -l
>flag!!


You are the victim of multiple typos, as well as some bad (or misdirected)
advice. The first person was missing a dash in the option (should
be -Wl,--subsystem,windows) and also telling you to link a library that
doesn't exist (-lwin32 will not work). The second person meant -lkernel32,
but that's a bad idea too, because kernel32 is linked automatically and
linking it twice can cause problems.

It is normal, by the way, for the linker to report not being able to find
the "file" -lfoo when really it can't find the library libfoo.a... just
one of the quirks of the GNU linker.

Here is a command line that works (I know it works because I cut and
pasted from the window where I just ran it):

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

The command line above tells the linker to use a (yes, not officially
documented yet, though it is mentioned in the FAQ at Cygnus) subsystem
option to make a GUI application. It also tells it to link two extra
libraries libuser32.a (user interface, window management and such) and
libgdi32.a (graphics device interface) (BTW, I believe that is also
mentioned in the FAQ at Cygnus).

There is also an option -mwindows which sets -Wl,--subsystem,windows and
links those libraries, along with a few others. So

gcc -o hellowin.exe hellowin.c -mwindows

Should also work (and I think that is also mentioned in the FAQ). Feel
free to ask if you have more problems.

Good luck,
Colin.

-- Colin Peters -- colin at fu.is.saga-u.ac.jp
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin
-- http://www.geocities.com/Tokyo/Towers/6162


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]