Jump to content
  • Advertisement
Sign in to follow this  
Corrosive

unresolved external error

This topic is 5122 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
Advertisement
You didn't post the error message. Also, put source code between [source] and [/source] tags, so that it's formatted correctly.

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
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.

Share this post


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

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
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!