Jump to content
  • Advertisement
Sign in to follow this  

Dynamic Class Help (again)

This topic is 5044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting the following errors in Microsoft Visual studio 2005 Beta and I can't figure out what I'm doing wrong. It is a DLL project by the way
   Creating library Debug/Engine.lib and object Debug/Engine.exp
Engine.obj : warning LNK4217: locally defined symbol ??1exception@std@@UAE@XZ (public: virtual __thiscall std::exception::~exception(void)) imported in function __unwindfunclet$??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z$0
Engine.obj : warning LNK4217: locally defined symbol ??0exception@std@@QAE@ABV01@@Z (public: __thiscall std::exception::exception(class std::exception const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::logic_error const &)" (??0logic_error@std@@QAE@ABV01@@Z)
Engine.obj : warning LNK4217: locally defined symbol __invalid_parameter imported in function "public: void __thiscall std::_Vector_const_iterator<class CMesh *,class std::allocator<class CMesh *> >::_Compat(class std::_Vector_const_iterator<class CMesh *,class std::allocator<class CMesh *> > const &)const " (?_Compat@?$_Vector_const_iterator@PAVCMesh@@V?$allocator@PAVCMesh@@@std@@@std@@QBEXABV12@@Z)
Engine.obj : warning LNK4217: locally defined symbol __CrtDbgReportW imported in function "public: void __thiscall std::_Vector_const_iterator<class CMesh *,class std::allocator<class CMesh *> >::_Compat(class std::_Vector_const_iterator<class CMesh *,class std::allocator<class CMesh *> > const &)const " (?_Compat@?$_Vector_const_iterator@PAVCMesh@@V?$allocator@PAVCMesh@@@std@@@std@@QBEXABV12@@Z)
Engine.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(void)" (__imp_??0exception@std@@QAE@XZ) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
Debug/Engine.dll : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Matt\My Documents\Visual Studio\Projects\Ender's Game\Source\Engine\Debug\BuildLog.htm"
Engine - 2 error(s), 5 warning(s)

Heres the relevant source (engine.h/engine.cpp)


#include <vector>
#include <windows.h>
#include <d3dx9.h>
#include <dinput.h>

#include "Mesh.h"
#include "Camera.h"
#include "PhysicsObject.h"
#include "MovingPhysicsObject.h"
#include "StaticPhysicsObject.h"
#include "StaticMesh.h"
#include "AnimatedMesh.h"
#include "InputAnimator.h"
#include "EngineLog.h"

using namespace std;

#ifdef _DLL // assume this is defined when we build the dll
#define _DYNLINK __declspec( dllexport)
#define _DYNLINK __declspec( dllimport)

class CEngine

	bool Init(D3DXVECTOR2 window_size);

	CMesh* CreateMesh();
	CInputAnimator* CreateInputAnimator();

	bool InitWindows();
	bool InitDirect3D();
	bool InitDirectInput();
	//Graphics stuff
	HWND hwnd;

	//Input stuff

	//Information variables
	D3DXVECTOR2 WindowSize;

	vector <CMesh*> Meshes;
	CEngineLog* Log;

extern "C"
#ifndef _DLL
	typedef CEngine* ( *PFNCREATEMYCLASS)();
	typedef void ( *PFNDELETEMYCLASS)( CEngine*);

	_DYNLINK CEngine* __stdcall  CreateMyClass() 
		return ( new CEngine());
	_DYNLINK void __stdcall DeleteMyClass ( CEngine* pObj) 
		delete pObj;
#endif //_DLL
} //extern C

#endif //Include guard


#include "Engine.h"

HINSTANCE		g_hinstThisDll;
static	BOOL			g_bCrippledOS	=	FALSE;
static	OSVERSIONINFO	g_osviVerInfo;

extern "C" int APIENTRY	DllMain	(	HINSTANCE	hInstance, 
									DWORD		dwReason, 
									LPVOID		lpReserved

    if	(	DLL_PROCESS_ATTACH	==	dwReason)
		    // Extension DLL one-time initialization
	        g_hinstThisDll	=	hInstance;

			g_osviVerInfo.dwOSVersionInfoSize	=	sizeof	(	OSVERSIONINFO);
			GetVersionEx(	&g_osviVerInfo);
			if (	VER_PLATFORM_WIN32_WINDOWS	==	g_osviVerInfo.dwPlatformId)
					g_bCrippledOS	=	TRUE;


	return	(	TRUE);





bool CEngine::Init(D3DXVECTOR2 window_size)
	Log = new CEngineLog();

	return true;

CMesh* CEngine::CreateMesh()
	CMesh* mesh;
	mesh = new CMesh(pD3DDevice);
	return mesh;

CInputAnimator* CEngine::CreateInputAnimator()
	CInputAnimator* animator;

	return animator;

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    return DefWindowProc (hwnd, message, wParam, lParam);

bool CEngine::InitWindows()
	HINSTANCE hInstance = GetModuleHandle(0);
	WNDCLASSEX wincl;     

    /* The Window structure */
    wincl.hInstance = hInstance;
    wincl.lpszClassName = "Engine";
    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 Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           "Engine",         /* Classname */
           "Ender's Game",      /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           0,       /* Windows decides the position */
           0,       /* where the window ends up on the screen */
           800,                 /* The programs width */
           600,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hInstance,           /* Program Instance handler */
           NULL                 /* No Window Creation data */

    /* Make the window visible on the screen */
    ShowWindow (hwnd, SW_SHOW);

	return true;

bool CEngine::InitDirect3D()
	Log->LogInfo("Initalizing direct3D...");
    // Create the D3D object, which is needed to create the D3DDevice.
	pD3D = Direct3DCreate9(D3D_SDK_VERSION);
		Log->LogError("\tFailed to create main direct3D object");
		return false;
    Log->LogInfo("\tCreated main direct3D object");

    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

                                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pD3DDevice)))
        Log->LogError("\tFailed to create the device");
        return false;
    Log->LogInfo("\tDevice created");
	if(pD3DDevice == NULL) {
        Log->LogError("\tDevice is NULL");
        return false;

	//Set Render States
    pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
    pD3DDevice->SetRenderState(D3DRS_CULLMODE , D3DCULL_NONE);
    pD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);

    Log->LogInfo("\tRender states set");
    Log->LogInfo("Direct3D initalized...");
	return true;

bool CEngine::InitDirectInput()
	Log->LogInfo("Initalizing Direct Input...");
	//Initalize main direct input object
	if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, 
              (void**)&pDirectInput, NULL))) {
        Log->LogError("\tFailed to create Direct Input object");
        return false;
    Log->LogInfo("\tCreated main Direct Input object");

	//Setup keyboard
    if (FAILED(pDirectInput->CreateDevice(GUID_SysKeyboard, &pKeyboard, NULL))) {
        Log->LogError("Failed to created keyboard device");
        return false;
    if(FAILED(pKeyboard->SetDataFormat(&c_dfDIKeyboard))) { 
        Log->LogError("Failed to set data format");
        return false;
    if (FAILED(pKeyboard->SetCooperativeLevel(hwnd, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE))) { 
        Log->LogError("Failed to set cooperative level");
        return false;

    if (FAILED(pKeyboard->Acquire())){
        Log->LogError("Failed to acquire keyboard");
        return false;

	Log->LogInfo("\tInitalized keyboard");

	if (FAILED(pDirectInput->CreateDevice(GUID_SysMouse, &pMouse, NULL))) {
		Log->LogError("Failed to acquire mouse");
		return false;

	if (FAILED(pMouse->SetDataFormat(&c_dfDIMouse))) {
		Log->LogError("Failed to set data format (mouse)");
		return false;

	if (FAILED(pMouse->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND))) {
		Log->LogError("Failed to set cooperative level (mouse)");
		return false;

	if (FAILED(pMouse->Acquire())) {
		Log->LogInfo("Failed to acquire keyboard");
        return false;
	Log->LogInfo("\tInitalized mouse");
	Log->LogInfo("Direct Input initalized");

	return true;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!