Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 11, 2001 Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Folks, Probably there is some subtle configuration problem in my setup, but I cannot find it! The following source code (a very standard simple Windows program, compilable in every other compiler in this machine), gives the error message in the subject when compiled as follows: C:\Work>sc -WA olawin -o olawinsc.exe link olawin,olawinsc,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved olawin.obj(olawin) Error 42: Symbol Undefined _GetStockObject@4 --- errorlevel 1 Can you advise me? TIA, Cesar ----------------------------->8 OLAWIN.C #include <windows.h> /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp"; int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof(WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use light-gray as the background of the window */ wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); /* Register the window class, if fail quit the program */ if(!RegisterClassEx(&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "Windows App", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 544, /* The programs width */ 375, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow(hwnd, nFunsterStil); /* Run the message loop. It will run until GetMessage( ) returns 0 */ while(GetMessage(&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage( ) gave */ return messages.wParam; } /* This function is called by the Windows function DispatchMessage( ) */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; switch (message) /* handle the messages */ { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); DrawText(hdc, "Alo Windows 98!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } |
July 11, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cesar Rabak | Include GDI32.LIB
Jan
Cesar Rabak wrote:
> Folks,
>
> Probably there is some subtle configuration problem in my setup, but I cannot find it!
>
> The following source code (a very standard simple Windows program, compilable in every other compiler in this machine), gives the error message in the subject when compiled as follows:
>
> C:\Work>sc -WA olawin -o olawinsc.exe
> link olawin,olawinsc,,user32+kernel32/noi;
> OPTLINK (R) for Win32 Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
>
> olawin.obj(olawin)
> Error 42: Symbol Undefined _GetStockObject@4
>
> --- errorlevel 1
>
> Can you advise me?
>
> TIA,
>
> Cesar
>
> ----------------------------->8 OLAWIN.C
> #include <windows.h>
>
> /* Declare Windows procedure */
> LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
> /* Make the class name into a global variable */
> char szClassName[ ] = "WindowsApp";
> int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
> LPSTR lpszArgument, int nFunsterStil)
>
> {
> HWND hwnd; /* This is the handle for our window */
> MSG messages; /* Here messages to the application are
> saved */
> WNDCLASSEX wincl; /* Data structure for the windowclass */
>
> /* The Window structure */
> wincl.hInstance = hThisInstance;
> wincl.lpszClassName = szClassName;
> wincl.lpfnWndProc = WindowProcedure; /* This function is called
> by windows */
> wincl.style = CS_DBLCLKS; /* Catch double-clicks */
> wincl.cbSize = sizeof(WNDCLASSEX);
>
> /* Use default icon and mouse-pointer */
> wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
> wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
> wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
> wincl.lpszMenuName = NULL; /* No menu */
> wincl.cbClsExtra = 0; /* No extra bytes after
> the window class */
> wincl.cbWndExtra = 0; /* structure or the
> window instance */
> /* Use light-gray as the background of the window */
> wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
>
> /* Register the window class, if fail quit the program */
> if(!RegisterClassEx(&wincl)) return 0;
>
> /* The class is registered, let's create the program*/
> hwnd = CreateWindowEx(
> 0, /* Extended possibilites for variation
> */
> szClassName, /* Classname */
> "Windows App", /* Title Text */
> WS_OVERLAPPEDWINDOW, /* default window */
> CW_USEDEFAULT, /* Windows decides the position */
> CW_USEDEFAULT, /* where the window ends up on the
> screen */
> 544, /* The programs width */
> 375, /* and height in pixels */
> HWND_DESKTOP, /* The window is a child-window to
> desktop */
> NULL, /* No menu */
> hThisInstance, /* Program Instance handler */
> NULL /* No Window Creation data */
> );
>
> /* Make the window visible on the screen */
> ShowWindow(hwnd, nFunsterStil);
> /* Run the message loop. It will run until GetMessage( ) returns 0
> */
> while(GetMessage(&messages, NULL, 0, 0))
> {
> /* Translate virtual-key messages into character messages */
> TranslateMessage(&messages);
> /* Send message to WindowProcedure */
> DispatchMessage(&messages);
> }
>
> /* The program return-value is 0 - The value that PostQuitMessage( )
> gave */
> return messages.wParam;
> }
>
> /* This function is called by the Windows function DispatchMessage( ) */
> LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
> LPARAM lParam)
> {
> HDC hdc;
> PAINTSTRUCT ps;
> RECT rect;
>
> switch (message) /* handle the messages */
> {
> case WM_PAINT:
> hdc = BeginPaint(hwnd, &ps);
> GetClientRect(hwnd, &rect);
> DrawText(hdc, "Alo Windows 98!", -1, &rect,
> DT_SINGLELINE | DT_CENTER | DT_VCENTER);
> EndPaint(hwnd, &ps);
> return 0;
>
> case WM_DESTROY:
> PostQuitMessage(0); /* send a WM_QUIT to the message
> queue */
> break;
> default: /* for messages that we don't deal
> with */
> return DefWindowProc(hwnd, message, wParam, lParam);
> }
> return 0;
> }
|
July 11, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | Jan Knepper wrote: > > Include GDI32.LIB > Jan, Since gdi32.lib did not come in dm818c.zip, I attempted to import it, but I still get the same error: C:\dm\lib>implib Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. output library file (.lib) gdi32 dll or def file (.dll (default) or .def) \windows\system\gdi32 Input is a Windows NT DLL file 'GDI32.dll'. Output is a Windows NT import library. Digital Mars Import Library Creator complete. C:\dm\lib>dir O volume da unidade C é CANJICA O número de série do volume é 2B67-1D0B Pasta de C:\dm\lib . <DIR> 07/07/01 20:53 . .. <DIR> 07/07/01 20:53 .. ADVAPI32 LIB 53.760 08/08/96 20:30 ADVAPI32.LIB COMCTL32 LIB 9.728 24/06/01 17:41 COMCTL32.LIB COMDLG32 LIB 3.072 08/08/96 20:30 COMDLG32.LIB CT OBJ 1.958 23/03/01 11:28 ct.obj CTL3D32 LIB 2.560 04/12/95 9:07 CTL3D32.LIB GC LIB 11.776 19/06/01 16:10 gc.lib GDI32 LIB 36.864 11/07/01 0:40 gdi32.lib KERNEL32 LIB 79.872 08/08/96 20:30 KERNEL32.LIB OLE32 LIB 32.256 08/08/96 20:30 OLE32.LIB OLEAUT32 LIB 24.064 14/08/96 6:24 OLEAUT32.LIB SDC LIB 392.192 23/03/01 11:33 sdc.lib SDL LIB 399.872 23/03/01 11:33 sdl.lib SDM LIB 375.296 23/03/01 11:33 sdm.lib SDS LIB 370.176 23/03/01 11:33 sds.lib SDX LIB 365.056 03/04/01 15:07 SDX.LIB SNN LIB 511.488 26/06/01 12:19 snn.LIB USER32 LIB 60.416 08/08/96 20:30 USER32.LIB UUID LIB 170.496 14/08/96 6:24 UUID.LIB 18 arquivo(s) 2.900.902 bytes 2 pasta(s) 805.56 MB livre(s) C:\dm\lib>cd\work C:\Work>link olawin,olawinsc,,user32+gdi32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved olawin.obj(olawin) Error 42: Symbol Undefined _GetStockObject@4 |
July 11, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cesar Rabak | I think you need to throw the /SYSTEM switch for system .DLL's...
Jan
Cesar Rabak wrote:
> Jan Knepper wrote:
> >
> > Include GDI32.LIB
> >
> Jan,
>
> Since gdi32.lib did not come in dm818c.zip, I attempted to import it, but I still get the same error:
>
> C:\dm\lib>implib
> Digital Mars Import Library Manager Version 7.6B1n
> Copyright (C) Digital Mars 2000. All Rights Reserved.
> output library file (.lib) gdi32
> dll or def file (.dll (default) or .def) \windows\system\gdi32
> Input is a Windows NT DLL file 'GDI32.dll'.
> Output is a Windows NT import library.
> Digital Mars Import Library Creator complete.
>
> C:\dm\lib>dir
>
> O volume da unidade C é CANJICA
> O número de série do volume é 2B67-1D0B
> Pasta de C:\dm\lib
>
> . <DIR> 07/07/01 20:53 .
> .. <DIR> 07/07/01 20:53 ..
> ADVAPI32 LIB 53.760 08/08/96 20:30 ADVAPI32.LIB
> COMCTL32 LIB 9.728 24/06/01 17:41 COMCTL32.LIB
> COMDLG32 LIB 3.072 08/08/96 20:30 COMDLG32.LIB
> CT OBJ 1.958 23/03/01 11:28 ct.obj
> CTL3D32 LIB 2.560 04/12/95 9:07 CTL3D32.LIB
> GC LIB 11.776 19/06/01 16:10 gc.lib
> GDI32 LIB 36.864 11/07/01 0:40 gdi32.lib
> KERNEL32 LIB 79.872 08/08/96 20:30 KERNEL32.LIB
> OLE32 LIB 32.256 08/08/96 20:30 OLE32.LIB
> OLEAUT32 LIB 24.064 14/08/96 6:24 OLEAUT32.LIB
> SDC LIB 392.192 23/03/01 11:33 sdc.lib
> SDL LIB 399.872 23/03/01 11:33 sdl.lib
> SDM LIB 375.296 23/03/01 11:33 sdm.lib
> SDS LIB 370.176 23/03/01 11:33 sds.lib
> SDX LIB 365.056 03/04/01 15:07 SDX.LIB
> SNN LIB 511.488 26/06/01 12:19 snn.LIB
> USER32 LIB 60.416 08/08/96 20:30 USER32.LIB
> UUID LIB 170.496 14/08/96 6:24 UUID.LIB
> 18 arquivo(s) 2.900.902 bytes
> 2 pasta(s) 805.56 MB livre(s)
>
> C:\dm\lib>cd\work
>
> C:\Work>link olawin,olawinsc,,user32+gdi32+kernel32/noi;
> OPTLINK (R) for Win32 Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
>
> olawin.obj(olawin)
> Error 42: Symbol Undefined _GetStockObject@4
|
July 12, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | Jan Knepper wrote:
>
> I think you need to throw the /SYSTEM switch for system .DLL's...
>
Jan,
This is not enough... the /system swith appends underscores as prefix for the symbol names. However, an inspection of the generated library shows that the suffix name mangling (the '@x', where x is a number), is missing.
Cesar
|
July 12, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cesar Rabak | Sorry, I think you need to run COFF2OMF on the lib or did I just run that on the MSVC-- .lib files???
Cesar Rabak wrote:
> Jan Knepper wrote:
> >
> > I think you need to throw the /SYSTEM switch for system .DLL's...
> >
> Jan,
>
> This is not enough... the /system swith appends underscores as prefix for the symbol names. However, an inspection of the generated library shows that the suffix name mangling (the '@x', where x is a number), is missing.
>
> Cesar
|
July 19, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | I met the same problem. But when I execute COFF2OMF gdi32.lib, nothing seems happend. Jan Knepper <jan@smartsoft.cc> wrote in message news:3B4DA842.55E09EFF@smartsoft.cc... > Sorry, I think you need to run COFF2OMF on the lib or did I just run that on the MSVC-- .lib files??? > > Cesar Rabak wrote: > > > Jan Knepper wrote: > > > > > > I think you need to throw the /SYSTEM switch for system .DLL's... > > > > > Jan, > > > > This is not enough... the /system swith appends underscores as prefix for the symbol names. However, an inspection of the generated library shows that the suffix name mangling (the '@x', where x is a number), is missing. > > > > Cesar > |
July 19, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to danny | It should change the .LIB file from COFF object format to OMF object format after which the functions should be visible to the compiler.
Jan
danny wrote:
> I met the same problem.
> But when I execute COFF2OMF gdi32.lib, nothing seems happend.
>
> Jan Knepper <jan@smartsoft.cc> wrote in message news:3B4DA842.55E09EFF@smartsoft.cc...
> > Sorry, I think you need to run COFF2OMF on the lib or did I just run that on the MSVC-- .lib files???
> >
> > Cesar Rabak wrote:
> >
> > > Jan Knepper wrote:
> > > >
> > > > I think you need to throw the /SYSTEM switch for system .DLL's...
> > > >
> > > Jan,
> > >
> > > This is not enough... the /system swith appends underscores as prefix for the symbol names. However, an inspection of the generated library shows that the suffix name mangling (the '@x', where x is a number), is missing.
> > >
> > > Cesar
> >
|
July 20, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | but I use borland's COFF2OMF tool, it said the gdi32.lib which I import from gdi32.dll is already OMF format. Jan Knepper <jan@smartsoft.cc> wrote in message news:3B5700D4.F56C2236@smartsoft.cc... > It should change the .LIB file from COFF object format to OMF object format > after which the functions should be visible to the compiler. > > Jan > > > > danny wrote: > > > I met the same problem. > > But when I execute COFF2OMF gdi32.lib, nothing seems happend. > > > > Jan Knepper <jan@smartsoft.cc> wrote in message news:3B4DA842.55E09EFF@smartsoft.cc... > > > Sorry, I think you need to run COFF2OMF on the lib or did I just run that > > > on the MSVC-- .lib files??? > > > > > > Cesar Rabak wrote: > > > > > > > Jan Knepper wrote: > > > > > > > > > > I think you need to throw the /SYSTEM switch for system .DLL's... > > > > > > > > > Jan, > > > > > > > > This is not enough... the /system swith appends underscores as prefix > > > > for the symbol names. However, an inspection of the generated library > > > > shows that the suffix name mangling (the '@x', where x is a number), is > > > > missing. > > > > > > > > Cesar > > > > |
July 20, 2001 Re: Error 42: Symbol Undefined _GetStockObject@4 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | Jan Knepper wrote:
>
> It should change the .LIB file from COFF object format to OMF object format after which the functions should be visible to the compiler.
>
Jan,
Up this we all agree. The question which remains to get a solution is what switch or workaround to use in order to have the names decorated the way the compiler expects.
Cesar
|
Copyright © 1999-2021 by the D Language Foundation