?
Solved

DllGetClassObject Errors during compile

Posted on 2007-10-08
17
Medium Priority
?
901 Views
Last Modified: 2013-12-14
The following code give me errors (below)

HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}

IVdjPluginDevice.h
//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJCLASSGUID_DEFINED
#define VDJCLASSGUID_DEFINED
static const GUID CLSID_VdjPlugin = { 0x2e1480fe, 0x4ff4, 0x4539, { 0x90, 0xb3, 0x64, 0x5f, 0x5d, 0x86, 0xf9, 0x3b } };
#else
extern static const GUID CLSID_VdjPlugin;
#endif

//////////////////////////////////////////////////////////////////////////
// DLL export function

#ifndef NODLLEXPORT
#ifdef __cplusplus
extern "C" {
#endif
VDJ_EXPORT HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject);
#ifdef __cplusplus
}
#endif
#endif

//////////////////////////////////////////////////////////////////////////

VdjPlugin.h
//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJDEVICEGUID_DEFINED
#define VDJDEVICEGUID_DEFINED
static const GUID IID_IVdjPluginDevice = { 0xc17ed55e, 0x76b2, 0x4fb7, { 0x99, 0x34, 0xbb, 0xb1, 0xaf, 0xcd, 0x8c, 0x7b } };
#else
extern static const GUID IID_IVdjPluginDevice;
#endif

//////////////////////////////////////////////////////////////////////////


COMPILE ERRORS
------ Build started: Project: TotalControl, Configuration: Debug Win32 ------
Linking...
   Creating library TotalControl.lib and object TotalControl.exp
TotalControl.obj : error LNK2028: unresolved token (0A000031) "public: __thiscall KC0DefaultMapper::KC0DefaultMapper(void)" (??0KC0DefaultMapper@@$$FQAE@XZ) referenced in function "extern "C" long __stdcall DllGetClassObject(struct _GUID const &,struct _GUID const &,void * *)" (?DllGetClassObject@@$$J212YGJABU_GUID@@0PAPAX@Z)
TotalControl.obj : error LNK2019: unresolved external symbol "public: __thiscall KC0DefaultMapper::KC0DefaultMapper(void)" (??0KC0DefaultMapper@@$$FQAE@XZ) referenced in function "extern "C" long __stdcall DllGetClassObject(struct _GUID const &,struct _GUID const &,void * *)" (?DllGetClassObject@@$$J212YGJABU_GUID@@0PAPAX@Z)
TotalControl.dll : fatal error LNK1120: 2 unresolved externals
0
Comment
Question by:makman111
  • 9
  • 8
17 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 20038323
Are you sure you added the .cpp file that holds "KC0DefaultMapper" to you project?
0
 

Author Comment

by:makman111
ID: 20038346
#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
//#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class
class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};
// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)
{
      *type = PLUGINDEVICE_TOTALCONTROL;
      return(PLUGINDEVICE_TOTALCONTROL);
}


HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
{
      char cmd[32];

      switch(slider)
      {
            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);
            SendCommand(cmd,chan);
            break;
      }
      return 0;
}

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
{
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
}

//-----------------------------------------------------------------------------
HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}
//-----------------------------------------------------------------------------
0
 

Author Comment

by:makman111
ID: 20038354
Do I need to move this code to from tc.cpp to tc.h?  If I do what would the new tc.cpp main() have in it?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 20038363
No, not at all, just make sure that it is included in your project. Go to "Project|Add..|Existing Item..." and navigate to that file. The, double-click and select "OK"  to add it to the project.

0
 

Author Comment

by:makman111
ID: 20038367
It's there (same as before).  Same problem.
0
 
LVL 86

Expert Comment

by:jkr
ID: 20038388
Hm, the constructor seems to be missing - what happens if you add

KC0DefaultMapper::KC0DefaultMapper() {

// empty
}

to your code?
0
 
LVL 86

Expert Comment

by:jkr
ID: 20038392
>>Hm, the constructor seems to be missing

Make that read

Hm, the default constructor seems to be missing
0
 

Author Comment

by:makman111
ID: 20038401
That should be in the class definitation correct?

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

      KC0DefaultMapper::KC0DefaultMapper()  
     {return 0;}
};

or outside of it

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};

KC0DefaultMapper::KC0DefaultMapper()  
{return 0;}
0
 
LVL 86

Expert Comment

by:jkr
ID: 20038407
You can choose either location, but constructors don't return values, so that has to be either

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

      KC0DefaultMapper::KC0DefaultMapper()  {}
};

or

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};

KC0DefaultMapper::KC0DefaultMapper()  {}

0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 2000 total points
ID: 20038409
... and be sure to check the docs if there are any members to initialize. Yet the class does not seem to have any, so we should be safe here.
0
 

Author Comment

by:makman111
ID: 20038471
class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);
};

KC0DefaultMapper::KC0DefaultMapper(){
      //empty
}

Gives me:

------ Build started: Project: TotalControl, Configuration: Debug Win32 ------
Compiling...
TotalControl.cpp
.\TotalControl.cpp(13) : error C2653: 'KC0DefaultMapper' : is not a class or namespace name
.\TotalControl.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\TotalControl.cpp(13) : warning C4508: 'KC0DefaultMapper' : function should return a value; 'void' return type assumed
.\TotalControl.cpp(70) : error C2061: syntax error : identifier 'KC0DefaultMapper'
TotalControl - 3 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 2000 total points
ID: 20038482
And what do you get using

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

      KC0DefaultMapper::KC0DefaultMapper()  {}
};

?
0
 

Author Comment

by:makman111
ID: 20038499
Compiling...
TotalControl.cpp
.\TotalControl.cpp(13) : error C2653: 'KC0DefaultMapper' : is not a class or namespace name
.\TotalControl.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\TotalControl.cpp(13) : warning C4508: 'KC0DefaultMapper' : function should return a value; 'void' return type assumed
.\TotalControl.cpp(25) : error C2535: 'KC0DefaultMapper::KC0DefaultMapper(void)' : member function already defined or declared
        .\TotalControl.cpp(19) : see declaration of 'KC0DefaultMapper::KC0DefaultMapper'
.\TotalControl.cpp(69) : error C2061: syntax error : identifier 'KC0DefaultMapper'
0
 

Author Comment

by:makman111
ID: 20038503
I did some messing around - this worked....  But I do not know why

#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
//#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};
KC0DefaultMapper::KC0DefaultMapper()  {}
// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)
{
      *type = PLUGINDEVICE_TOTALCONTROL;
      return(PLUGINDEVICE_TOTALCONTROL);
}


HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
{
      char cmd[32];

      switch(slider)
      {
            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);
            SendCommand(cmd,chan);
            break;
      }
      return 0;
}

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
{
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
}

//-----------------------------------------------------------------------------
HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}
//-----------------------------------------------------------------------------
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 20038509
>>KC0DefaultMapper::KC0DefaultMapper()  {}

That should have done it. May a typo or something like that that in the previous versions.
0
 

Author Comment

by:makman111
ID: 20038521
Yeah - your a probably right.  Thanks for the help.  I have another question coming - you are great, please check it out.

http://www.experts-exchange.com/Programming/Languages/CPP/Q_22880489.html
0
 
LVL 86

Expert Comment

by:jkr
ID: 20038531
I gotta hit the sack (we're talking MEDT at the moment), will take a look tomorrow ;o)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question