public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: more information on my problem
@ 1997-12-17 19:36 Colin Peters
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Peters @ 1997-12-17 19:36 UTC (permalink / raw)
  To: Kurt Häusler; +Cc: GNU-Win32

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".

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: more information on my problem
@ 1997-12-17 23:51 Colin Peters
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Peters @ 1997-12-17 23:51 UTC (permalink / raw)
  To: Kurt Häusler; +Cc: GNU-Win32

From: Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
To: Kurt H?sler <turtill@ihug.co.nz>
Cc: GNU-Win32 <gnu-win32@cygnus.com>
Date: Thursday, December 18, 1997 1:18 PM
Subject: Re: more information on my problem

[snip]
>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.


Actually that won't work (sorry). -mwindows can only be used as an option
for linking, so you have to do it in two steps if you want to do it that
way:

gcc -o hellowin.o hellowin.c
gcc -o hellowin.exe hellowin.o -mwindows

That should work.

Sorry about that,
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread
* more information on my problem
@ 1997-12-17 17:43 Kurt Häusler
  0 siblings, 0 replies; 3+ messages in thread
From: Kurt Häusler @ 1997-12-17 17:43 UTC (permalink / raw)
  To: gnu-win32

[-- Attachment #1: Type: text/plain, Size: 1738 bytes --]

This is in regard to being able to compile console apps fine but not a
program using the win32 api.  I have attached the source file.
This is my command line:
gcc -o hellowin.exe hellowin.c

And this is compiler output stuff like:

<similar lines trimmed>

C:\WINDOWS\TEMP\cc0010611.o(.text+0x13f):hellowin.c: undefined reference to
`BeginPaint@8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x151):hellowin.c: undefined reference to
`GetClientRect@8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x167):hellowin.c: undefined reference to
`DrawTextA@20'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x174):hellowin.c: undefined reference to
`EndPaint@8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x17f):hellowin.c: undefined reference to
`PostQuitMessage@4'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x199):hellowin.c: undefined reference to
`DefWindowProcA@16'
gcc: Internal compiler error: program ld got fatal signal 1

Three people tried to help by pointing to various sites etc.  that I have
already read and understand but don't cover my problem.  They seem to be
only concerned with writing UNIX style console apps (but how many of them
need to be written for a GUI like windows?).

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!!

I have set up all the paths and environment vars correctly.  Please help . I
like the idea of the Cygnus project and I want to give it a fair go before I
give up and move on to paying for Visual C++

Thanks a lot

Kurt



[-- Attachment #2: Hellowin.c --]
[-- Type: text/x-c, Size: 2743 bytes --]

/*--------------------------------------------------------
   HELLOWIN.C -- Displays "Hello, Windows" in client area
                 (c) Charles Petzold, 1992
  --------------------------------------------------------*/

#include <windows.h>

LRESULT CALLBACK WndProc (HWND, UINT, UINT, LONG) ;

int WINAPI WinMain (HANDLE hInstance, HANDLE hPrevInstance,
                    LPSTR lpszCmdParam, int nCmdShow)
     {
     static char szAppName[] = "HelloWin" ;
     HWND        hwnd ;
     MSG         msg ;
     WNDCLASS    wndclass ;

     if (!hPrevInstance)
          {
          wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
          wndclass.lpfnWndProc   = WndProc ;
          wndclass.cbClsExtra    = 0 ;
          wndclass.cbWndExtra    = 0 ;
          wndclass.hInstance     = hInstance ;
          wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
          wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
          wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
          wndclass.lpszMenuName  = NULL ;
          wndclass.lpszClassName = szAppName ;

          RegisterClass (&wndclass) ;
	  }

     hwnd = CreateWindow (szAppName,         // window class name
		    "The Hello Program",     // window caption
                    WS_OVERLAPPEDWINDOW,     // window style
                    CW_USEDEFAULT,           // initial x position
                    CW_USEDEFAULT,           // initial y position
                    CW_USEDEFAULT,           // initial x size
                    CW_USEDEFAULT,           // initial y size
                    NULL,                    // parent window handle
                    NULL,                    // window menu handle
                    hInstance,               // program instance handle
		    NULL) ;		     // creation parameters

     ShowWindow (hwnd, nCmdShow) ;
     UpdateWindow (hwnd) ;

     while (GetMessage (&msg, NULL, 0, 0))
          {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
          }
     return msg.wParam ;
     }

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam,
                                                          LONG lParam)
     {
     HDC         hdc ;
     PAINTSTRUCT ps ;
     RECT	 rect ;

     switch (message)
          {
          case WM_PAINT:
	       hdc = BeginPaint (hwnd, &ps) ;

               GetClientRect (hwnd, &rect) ;

	       DrawText (hdc, "Hello, Windows!", -1, &rect,
			 DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;

	       EndPaint (hwnd, &ps) ;
               return 0 ;

          case WM_DESTROY:
               PostQuitMessage (0) ;
               return 0 ;
          }

     return DefWindowProc (hwnd, message, wParam, lParam) ;
     }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-12-17 23:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-17 19:36 more information on my problem Colin Peters
  -- strict thread matches above, loose matches on Subject: below --
1997-12-17 23:51 Colin Peters
1997-12-17 17:43 Kurt Häusler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).