Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1325
  • Last Modified:

unresolved external symbol CLSID_DirectDraw

Here's the code:

...
<include ddraw.h>
...
void Test()
{
    HRESULT hr;
    HINSTANCE hinst;
    FARPROC dgco;
    IClassFactory*pcf;
   
    hinst=LoadLibrary("ddraw.dll");
    if (hinst) {
   
        dgco=GetProcAddress(hinst,"DllGetClassObject");

        hr=( (HRESULT(WINAPI*)(REFCLSID,REFIID,IClassFactory**)) dgco)
             (CLSID_DirectDraw,
              IID_IClassFactory,
              &pcf);
       
        if (S_OK==hr) {
          AfxMessageBox("OK");
          pcf->Release();
        }

        FreeLibrary(hinst);
    }
}

It compiles OK, but at link time, I get the following error:

error LNK2001: unresolved external symbol _CLSID_DirectDraw

Linking with ddraw.lib does not help.

CLSID_DirectDraw is declared in ddraw.h:

#if defined( _WIN32 ) && !defined( _NO_COM )
DEFINE_GUID( CLSID_DirectDraw,                  0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 );
DEFINE_GUID( CLSID_DirectDrawClipper,           0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 );
DEFINE_GUID( IID_IDirectDraw,                  0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDraw2,                  0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
DEFINE_GUID( IID_IDirectDrawSurface,            0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDrawSurface2,            0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );

DEFINE_GUID( IID_IDirectDrawPalette,            0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDrawClipper,            0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
                 
#endif

Why do I get the unresolved external symbol error ?
0
byang
Asked:
byang
  • 3
  • 2
1 Solution
 
galkinCommented:
Include ddraw.lib into your project
0
 
chensuCommented:
Since you are linking ddraw.dll dynamically (why do you want to do so?), I think you shouldn't link ddraw.lib.

Either

#define INITGUID
#include <objbase.h>
#include <ddraw.h>

or

#include <objbase.h>
#include <initguid.h>
#include <ddraw.h>

0
 
byangAuthor Commented:
galkin: I tried linking with ddraw.lib, and still got the same error. This is mentioned in my question and I'm afraid you missed it.

chensu: I'm experiementing to see if I can manually obtain usable interface pointers thru DllGetClassObject(), without going thru SCM. I think as long as I pay attention to threading models, it should work. I'll try your INITGUID define. Since my test program is MFC, I assume all the necessary headers are included already.

Also, please don't answer this question for now. MS developer support news emailed on April 21 contains this link about unresolved CLSID/IID in internet client SDK, which might answer my question. I'll check it first.

http://support.microsoft.com/support/kb/articles/Q182/1/17.asp
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
chensuCommented:
When #include <initguid.h> is used after #include <objbase.h>, DEFINE_GUID will define the GUID instead of declaring it.

The KB article does not apply to your case.
0
 
byangAuthor Commented:
You're right, DEFINE_GUID has 2 expansions, depending on if INITGUID is defined.

Answer the question and I'll accept it.
0
 
chensuCommented:
Thank you.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now