www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Error 42: Symbol Undefined _GetStockObject 4

reply Cesar Rabak <csrabak uol.com.br> writes:
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;
}
Jul 10 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
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;
 }

Jul 10 2001
parent reply Cesar Rabak <csrabak uol.com.br> writes:
Jan Knepper wrote:
 
 Include GDI32.LIB
 

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
Jul 10 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
I think you need to throw the /SYSTEM switch for system .DLL's...

Jan



Cesar Rabak wrote:

 Jan Knepper wrote:
 Include GDI32.LIB

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

Jul 10 2001
parent reply Cesar Rabak <csrabak uol.com.br> writes:
Jan Knepper wrote:
 
 I think you need to throw the /SYSTEM switch for system .DLL's...
 

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
Jul 12 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
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...

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

Jul 12 2001
parent reply "danny" <danny bj.col.com.cn> writes:
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...

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


Jul 19 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
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...

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



Jul 19 2001
next sibling parent "¶ÎÄþÔ¶" <danny server.hftc.com> writes:
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

 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



 on the MSVC-- .lib files???

 Cesar Rabak wrote:

 Jan Knepper wrote:
 I think you need to throw the /SYSTEM switch for system .DLL's...

This is not enough... the /system swith appends underscores as




 for the symbol names. However, an inspection of the generated




 shows that the suffix name mangling (the ' x', where x is a number),




 missing.

 Cesar




Jul 19 2001
prev sibling parent reply Cesar Rabak <csrabak uol.com.br> writes:
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.
 

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
Jul 19 2001
parent reply "Walter" <walter digitalmars.com> writes:
The only real solution is I'll email them to those that need 'em. They're
all on the CD.

Cesar Rabak wrote in message <3B578BC0.A54DE82B uol.com.br>...
Jan Knepper wrote:
 It should change the .LIB file from COFF object format to OMF object


 after which the functions should be visible to the compiler.

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

Jul 19 2001
next sibling parent Jan Knepper <jan smartsoft.cc> writes:
Walter wrote:

 The only real solution is I'll email them to those that need 'em. They're
 all on the CD.

I already sent GDI32.LIB if I am not mistaken... Jan
Jul 19 2001
prev sibling parent reply "danny" <danny bj.col.com.cn> writes:
why not put it on the web?so that we can download.
CD is not as reliable as the web I think:).

Walter <walter digitalmars.com> wrote in message
news:9j8bbn$147s$1 digitaldaemon.com...
 The only real solution is I'll email them to those that need 'em. They're
 all on the CD.

 Cesar Rabak wrote in message <3B578BC0.A54DE82B uol.com.br>...
Jan Knepper wrote:
 It should change the .LIB file from COFF object format to OMF object


 after which the functions should be visible to the compiler.

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


Jul 20 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
danny wrote:

 why not put it on the web?so that we can download.
 CD is not as reliable as the web I think:).

Uhhhh... The CD is basically the 'base'. The web just provides updates... (I think that would be the way to see it). Jan
Jul 20 2001
parent reply "danny" <danny bj.col.com.cn> writes:
 why not put it on the web?so that we can download.
 CD is not as reliable as the web I think:).

Uhhhh... The CD is basically the 'base'. The web just provides updates... (I think that would be the way to see it). Jan

I'm not at US, so get CD not as convenient as you think. I think if you want to let more people know digitalmars and like it , use web is the best way.
Jul 20 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
If you have a credit card (Visa/Master) it's relatively easy...
If you don't... Let me know where you are, I suspect China???
If so, you could be VERY lucky as my partner http://www.gentille.com/
http://www.mp3.com/gentille is going to China next week Thursday and could be
of some help in getting a CD-ROM into the country.

Thanks!
Jan



danny wrote:

 ? ? why not put it on the web?so that we can download.
 ? ? CD is not as reliable as the web I think:).
 ?
 ? Uhhhh... The CD is basically the 'base'. The web just provides updates...
 ? (I think that would be the way to see it).
 ?
 ? Jan

 I'm not at US, so get CD not as convenient as you think.
 I think if you want to let more people know digitalmars and
 like it , use web is the best way.

Jul 20 2001
parent "danny" <danny bj.col.com.cn> writes:
Thank's to Jan and Walter. I've received the lib.
And my application works well.

Jan Knepper <jan smartsoft.cc> wrote in message
news:3B5860BD.5E242C35 smartsoft.cc...
 If you have a credit card (Visa/Master) it's relatively easy...
 If you don't... Let me know where you are, I suspect China???
 If so, you could be VERY lucky as my partner http://www.gentille.com/
 http://www.mp3.com/gentille is going to China next week Thursday and could

 of some help in getting a CD-ROM into the country.

 Thanks!
 Jan



 danny wrote:

 ? ? why not put it on the web?so that we can download.
 ? ? CD is not as reliable as the web I think:).
 ?
 ? Uhhhh... The CD is basically the 'base'. The web just provides


 ? (I think that would be the way to see it).
 ?
 ? Jan

 I'm not at US, so get CD not as convenient as you think.
 I think if you want to let more people know digitalmars and
 like it , use web is the best way.


Jul 21 2001