Sign in to follow this  

unresolved external error

This topic is 4837 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

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]

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
*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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

c:\projetos\p1\anaueld3d.h(8) : error C2512: 'AnauEngine' : no appropriate default constructor available
Error 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...

Share this post


Link to post
Share on other sites
"...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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

This topic is 4837 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this