Skip to main content
GameDev.net gamedev.net
🔒 Locked

unresolved external error

Started by Corrosive Sep 13, 2004 at 7:33 PM 13 replies 2k views
Original Post
Corrosive
Corrosive
Hi guys... Im trying to make some Object Oriented Programming here. Im making a Dll and im using abstract classes. As i can see, the error points to the constructor of the derived class!!! I will place some code to clear any doubts!

//anauel_init.h
#include "anaueld3d.h"

HRESULT CreateRenderDevice(HINSTANCE hDll, AnauEngine **aDevice)
{
	if(!*aDevice)
	{
		
		*aDevice = new anaueld3d(hDll);//line possibly with error
		return 0; //return A_OK quando estiver implementado o controle de erros
	}
	return 1;
}


//anauel.h
#define Max_Instances 8

class AnauEngine
{
	protected:
		HWND   		a_HwndMain;
        HWND        a_Hwnd[Max_Instances];  //limite de janelas de renderização
		UINT 		a_HwndCount; //número de janelas usadas
		UINT	 	a_ActiveWindowId; // Identificação da janela ativa
		HINSTANCE	a_Dll; //Usado para carregar a DLL
		DWORD		a_largura; //largura da tela
		DWORD		a_altura; //altura da tela
		bool		a_Windowed; //tela cheia ou janela?
		char		a_GpuId[256]; //Modelo da GPU
		FILE	   *a_Log; //Arquivo de log
		bool		a_Ativo; //Verifica se o engine está rodando


	public:
		AnauEngine(HINSTANCE) {};
		virtual ~AnauEngine(void)=0;	

		virtual HRESULT Init(HWND) =0;  //Inicializa o dispositivo para a janela solicitada
		virtual void Release(void) =0;
		virtual bool Ativo(void) =0;

		virtual HRESULT UseWindow(UINT Hwnd) =0;
		virtual HRESULT Render(bool ClearPixel, bool ClearDepth, bool ClearStencil) =0;
		virtual void StopRender(void) =0;
		virtual HRESULT Clear(bool ClearPixel, bool ClearDepth, bool ClearStencil) =0;
		virtual void SetClearColor(float Red, float Green, float Blue) =0;
};

typedef struct AnauEngine *ANAUENGINE;



extern "C" 
{
	HRESULT CreateRenderDevice(HINSTANCE hDll, AnauEngine **pInterface);
	typedef HRESULT (*CREATERENDERDEVICE) (HINSTANCE hDll, AnauEngine **pInterface);
	HRESULT ReleaseRenderDevice(AnauEngine **pInterface);
	typedef HRESULT (*RELEASERENDERDEVICE) (AnauEngine **pInterface);

}


//anaueld3d.h
#define Max_Instances 8

class anaueld3d : public AnauEngine
{
public:
	anaueld3d(HINSTANCE a_Dll);
	~anaueld3d(void);

	HRESULT Init(HWND);
	BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);

	void Release(void);
	bool Ativo(void) {return a_Ativo;}
	HRESULT Render(bool, bool, bool);
	HRESULT Clear(bool, bool, bool);
	void StopRender(void);
	void SetClearColor(float, float, float);
	HRESULT UseWindow(UINT Hwnd);

private:
	//AnauD3DEnum			*a_Enum;
	LPDIRECT3D9			 a_D3D;
	LPDIRECT3DDEVICE9	 a_Device;
	LPDIRECT3DSWAPCHAIN9 a_Chain[Max_Instances];
	D3DPRESENT_PARAMETERS a_d3dpp;
	D3DCOLOR			 a_ClearColor;
	bool				 a_Rendering;
	bool				 a_Stencil;

	HRESULT				 Go(void);

	void Log(char *, ...);
};

I hope i didnt let things too much confused :) [Edited by - Corrosive on September 13, 2004 11:15:36 PM]
To code is to make things come to life ;)
Sneftel
Sneftel
You didn't post the error message. Also, put source code between [source] and [/source] tags, so that it's formatted correctly.
Corrosive
Corrosive
Sorry for that... Well, the error message is that:


anauel_Init.cpp
c:\projetos\p1\anauel.h(36) : warning C4099: 'AnauEngine' : type name first seen using 'class' now seen using 'struct'
c:\projetos\p1\anauel.h(6) : see declaration of 'AnauEngine'
Linking...
Creating library Debug/anaueld3d.lib and object Debug/anaueld3d.exp
anauel_Init.obj : error LNK2001: unresolved external symbol "public: __thiscall anaueld3d::anaueld3d(struct HINSTANCE__ *)" (??0anaueld3d@@QAE@PAUHINSTANCE__@@@Z)
Debug/anaueld3d.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.


i dont know exactly why its showing that!!!
To code is to make things come to life ;)
Sneftel
Sneftel
"unresolved external" generally means that a function was declared (by putting it in a .h file, for instance) but never defined in a source file. Make sure that anaueld3d::anaueld3d(struct HINSTANCE__ *) is given a body.
Corrosive
Corrosive
But anaueld3d is the constructor of the class derived from the base class(an abstract class). And i verified every declaration of the constructor and it means the HINSTANCE handle on every declaration. The only thing it dosnt appear to do is define the body of the constructor.
To code is to make things come to life ;)
Sneftel
Sneftel
Quote:
Original post by Corrosive
The only thing it dosnt appear to do is define the body of the constructor.
Right. And you need to.
xtrmntr
xtrmntr
Check the center source file you posted up above. You define your class and then define a typedef it as a structure. This is probably why its complaining.
Corrosive
Corrosive
*aDevice = new anaueld3d(hDll);

its all about this line... if i get this line out, it stops showing the error... one more thing, its a link error, not a compiler error. I probably messed up with some pointers, because when it try to get a pointer for aDevice, it shows the error, when try to call the constructor!
To code is to make things come to life ;)
emileej
emileej
Are you sure that you have defined the anaueld3d constructor? Cause that is why you get the unresolved external, as probably mentioned earlier. If you outcomment that line then sure you wont have any error because you wont be using that construtor and your average compiler couldnt care less about undeclared and unused symbols.
Emil Johansen- SMMOG AI designerhttp://smmog.com
Corrosive
Corrosive
Hi, well... just look at the abstract class(base class), the constructor is not virtual, its defined there. If i try to define the constructor anywhere else, it says that i dont have a apropriate default constructor. So, basically, i cant define it anymore. Its defined on the base class. The derived class dont need to define it again i think...
To code is to make things come to life ;)
emileej
emileej
Eh?

This is declared:
anaueld3d(HINSTANCE a_Dll);

It is used:
new anaueld3d(hDll);

And thous must be defined - regardless of whatever constructor(s) the base class of anaueld3d might have.

Could you post that error message regarding the default constructor along with the source referred to by that error?
Emil Johansen- SMMOG AI designerhttp://smmog.com
Corrosive
Corrosive
c:\projetos\p1\anaueld3d.h(8) : error C2512: 'AnauEngine' : no appropriate default constructor availableError executing cl.exe.


this is the error message


and this:

class anaueld3d : public AnauEngine{public:	anaueld3d(HINSTANCE hDll){a_Dll = hDll;};...     //rest of the class body..};


is the declaration of the constructor...
To code is to make things come to life ;)
emileej
emileej
"...along with the source referred to by that error...": Wheres line 8?
[edit]Ah wait... Your parent class does not have a default constructor - define your anaueld3d constructor like so:
anaueld3d::anaueld3d(HINSTANCE hDll):AnauEngine(hDll){//...
[/edit]
Emil Johansen- SMMOG AI designerhttp://smmog.com
Washu
Washu
Quote:
Original post by Corrosive
*** Source Snippet Removed ***

this is the error message


and this:

*** Source Snippet Removed ***

is the declaration of the constructor...

You need to call a parameterized constructor in the initializer list of anaueld3d.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
Corrosive
Corrosive
I defined the constructor as adviced, now all of the virtual functions are unresolved... Im a little new to abstract classes yet, thats why im getting all this trouble :) Trying to make my first Dll...

One more thing... Im going to the bed folks, thx for all the help!!! Tomorrow i will take a look on this post, good night!
To code is to make things come to life ;)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.