delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/12/17/18:32:37

From: turtill AT ihug DOT co DOT nz (=?iso-8859-1?Q?Kurt_H=E4usler?=)
Subject: more information on my problem
17 Dec 1997 18:32:37 -0800 :
Message-ID: <006801bd0b43$6aaa4520$26804dd1.cygnus.gnu-win32@cs116bf.ihug.co.nz>
Mime-Version: 1.0
To: <gnu-win32 AT cygnus DOT com>

This is a multi-part message in MIME format.

------=_NextPart_000_0065_01BD0BB0.6096FF20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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 AT 8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x151):hellowin.c: undefined reference to
`GetClientRect AT 8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x167):hellowin.c: undefined reference to
`DrawTextA AT 20'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x174):hellowin.c: undefined reference to
`EndPaint AT 8'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x17f):hellowin.c: undefined reference to
`PostQuitMessage AT 4'
C:\WINDOWS\TEMP\cc0010611.o(.text+0x199):hellowin.c: undefined reference to
`DefWindowProcA AT 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



------=_NextPart_000_0065_01BD0BB0.6096FF20
Content-Type: application/octet-stream;
	name="Hellowin.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="Hellowin.c"

/*--------------------------------------------------------
   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) ;
     }

------=_NextPart_000_0065_01BD0BB0.6096FF20--

-
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