"unresolved external symbol..." Going MAD!!!

Started by
5 comments, last by directNoob 17 years, 5 months ago
Hello. I´m in hell!!!
Quote: Creating library D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.lib and object D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.exp CCamera.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall IObject::~IObject(void)" (??1IObject@@UAE@XZ) referenced in function __unwindfunclet$??0CCamera@@QAE@XZ$0 CCamera.obj : error LNK2019: unresolved external symbol "public: __thiscall IObject::IObject(void)" (??0IObject@@QAE@XZ) referenced in function "public: __thiscall CCamera::CCamera(void)" (??0CCamera@@QAE@XZ) D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.dll : fatal error LNK1120: 2 unresolved externals
IObject is a abstract class. CCamera is derived from IObject. Both, the constructors from CCamera and the one of IObject are empty. Maybe mantionable, IObject is defined in another lib. I wanted to test the camera, but this problem is horrible. I have absolutly no idea why this doesn´t work! I also included all necessary header files. You are my last hope. I need this approach of deriving my object from IObject, because of the SceneManager and the ObjectManager. This is the first time I try to come up with stuff like that... And the IObject interface is also very comfortable for the occtree I try to implement. Thank for now Alex
Advertisement
Don't go mad; just read what the linker tells you. There are two things needed for the program to link, which aren't defined in your library but which are used. Since the project compiled and got to the linking phase, it is probably true that both these functions were 'promised' to exist by declaration in the header files, but never implemented by a definition.

What is missing is:
- a constructor of IObject with no parameters.
- a destructor of IObject.

Try the following solution: add this code somewhere in the project.
IObject::IObject() {};IObject::~IObject() {};


If it works, then place the code at the right spot (in IObject's implementation file(s)).

Greetz,

Illco
Quote:Original post by directNoob
Hello.

I´m in hell!!!

Quote:
Creating library D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.lib and object D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.exp
CCamera.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall IObject::~IObject(void)" (??1IObject@@UAE@XZ) referenced in function __unwindfunclet$??0CCamera@@QAE@XZ$0
CCamera.obj : error LNK2019: unresolved external symbol "public: __thiscall IObject::IObject(void)" (??0IObject@@QAE@XZ) referenced in function "public: __thiscall CCamera::CCamera(void)" (??0CCamera@@QAE@XZ)
D:\Programming\Game - Project\Engine Test\TheEngineTest\Debug\D3D.dll : fatal error LNK1120: 2 unresolved externals


IObject is a abstract class. CCamera is derived from IObject.
Both, the constructors from CCamera and the one of IObject are empty.


As far as the code you're trying to compile is concerned, they're not empty. They just plain don't exist (that's what "unresolved external symbol" means). Even if they're empty, if you've specified them, you need to implement them. If you have, then you'ce failed to correctly link to the library implementing them.

This problem would also be avoided in the first place by not specifying extranious functions in the first place. You probably want to make IObject have a virtual destructor, but there's no reason to specify a constructor if the default one would suffice.

And for empty dtors, I'd simply implement within the header:

class IObject {public:    virtual ~IObject() {}    virtual void InterfaceFunction1() = 0;    virtual void InterfaceFunction2() = 0;    virtual void InterfaceFunction3() = 0;};
Thanks for the fast response!!

First of all, I can tell you that you are right. :)
I forgot to link to the lib. Simply.
I thought, I don´t need the library, because I even don´t use the Camera class nor the IObject class. Just for inheritance.
I just prepared everything for usage. I have implemented everything. I also
have implemented the constructors and destructors. I thought about everything.
The fact is, IObject is not entirely abstract. Some functions I have implemented in the file IObject.cpp. What I want to say is that the CCamera class inherits implemented functionality from IObject beside of the abstract functions, which are implemented by the CCamera class.
I think, I have to load the static lib because I implemented some function before inheritance.
If this is not so, please correct me!!! ;)

I never got this problem before. That drove me crazy. I went nuts!!!

But now, something happend.
The character which should be rendered isn´t rendered. !Ä%§$&"/§(" NUTS

Thanks again!!!
Alex
The same problem again.

I try to make it short and understandable...

Now I implemented the camera CCamera.
CCamera is derived from IObject.

See the first problem...
The first problem was solved by including a lib.

But now, I dont know...
Here is the error code:

Main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CCamera::~CCamera(void)" (??1CCamera@@UAE@XZ) referenced in function _WinMain@16Main.obj : error LNK2019: unresolved external symbol "public: __thiscall CFrustum::~CFrustum(void)" (??1CFrustum@@QAE@XZ) referenced in function __unwindfunclet$??0CCamera@@QAE@XZ$0Main.obj : error LNK2019: unresolved external symbol "public: __thiscall CFrustum::CFrustum(void)" (??0CFrustum@@QAE@XZ) referenced in function "public: __thiscall CCamera::CCamera(void)" (??0CCamera@@QAE@XZ)Main.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CCamera::DrawObject(unsigned long)" (?DrawObject@CCamera@@UAEJK@Z)Main.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CCamera::DrawVector(unsigned long)" (?DrawVector@CCamera@@UAEJK@Z)Main.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CCamera::Initialize(void)" (?Initialize@CCamera@@UAEJXZ)Main.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CCamera::Release(void)" (?Release@CCamera@@UAEJXZ)


I have put a CCamera object into the main thread for testing. But than the compiler/linker came up with the text above.
All the functions in the text above are abstract and come form IObject, exept one function.
CreateBoundingVolume()
This function also comes from IObject, but its not listed in the error text.
The only diference is that CreateBoundingVolume() has its boby in the .h file.

CFrustum is the next. This class isnt derived. Its just used in CCamera.

I really have implemented everything. I also have included the libs.

Thanks
Alex
Basicly same as somebody noticed above. This compiler error you get when you have defined procedure but procedure has no body.

ERROR:
myheader.h
class A
{
public:
void myProc();
};

NO_ERROR
myheader.h
class A
{
public:
void myProc();
};

myheader.cpp
#include "myheader.h"
void A:myProc()
{
// do something
}

So beside that you define functions in header you need to provide a body for function...
Hi. Thanks.
I wouldn´t post this trivial problem, if I hadn´t thought about those suggestions.

Now, I put the whole CCamera and CFrustum into a new lib project in my VS.
I just copied the files and now it works.

But why????
The same files. I made absolutly no changes.
This is unbelievable.

Before it was like this:
in main.cpp
#pragma comment ( lib, "d3dx9.lib" ) #pragma comment ( lib, "../debug/CommonLib.lib" ) //<- implements IObject#pragma comment ( lib, "../debug/MathLib.lib" )#pragma comment	( lib, "../debug/D3D.lib" )       //<- implements CCamera and CFrustum#pragma comment ( lib, "../debug/RendererLib.lib" ) 


And every function has its own body.
There is no function without body neither IObject nor CCamera nor CFrustum.

The D3D.lib is actually a dll.

I solved the problem and this is satisfying for now.
I just want every D3D functionality within D3D.dll.

Is this a good idea?

Thanks
Alex

This topic is closed to new replies.

Advertisement