undefined reference to blah blah blah....

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

undefined reference to blah blah blah....

Post by benny53 »

Ok,I'm making a simple game engine,and now,my compiler is going crazy on me. Its saying I have undefined references to my parent classes. Here is the code for two classes,one in which is getting a linker error:

ILoadedMesh(linker error/parent)

Code: Select all

#ifndef _ILOADEDMESH_H_
#define _ILOADEDMESH_H_

#include "includes.hpp"
#include "IBaseMesh.hpp"
#include "IManager.hpp"

class DLL_EXPORT ILoadedMesh : public IBaseMesh
{
public:
   ILoadedMesh(IManager* mgr,const c8* file);
   ~ILoadedMesh();
};

#endif // _ILOADEDMESH_H_
CLoadedMesh(child class)

Code: Select all

#ifndef _CLOADEDMESH_H_
#define _CLOADEDMESH_H_

#include "includes.hpp"
#include "IManager.hpp"
#include "ILoadedMesh.hpp"

class DLL_EXPORT CLoadedMesh : public ILoadedMesh
{
public:
   CLoadedMesh(IManager* mgr,const c8* file);
   ~CLoadedMesh();
};

#endif // _CLOADEDMESH_H_
So what causes these errors? Help would be greatly appreciated.
Xharock
Posts: 71
Joined: Wed May 10, 2006 3:50 pm

Post by Xharock »

Hmm not sure whether this would cause linker errors but in your child class you only need to include "ILoadedMesh.hpp" as in that file it also includes the other two. So essentially you're including the same files twice. Could you post the errors you are receiving? That might help.
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

What does DLL_EXPORT evaluate to?
Are the functions declared in ILoadedMesh and IBaseMesh all implemented?
What are the exactly are the error messages?
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

#define DLL_EXPORT __declspec (dllexport)

IBase has all of its functions declared with the code in its own class. The linker errors say there is an undefined reference to the constructors and deconstructors of ILoadedMesh in CLoadedMesh.o
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

benny53 wrote:The linker errors say there is an undefined reference to the constructors and deconstructors of ILoadedMesh in CLoadedMesh.o
So did you define these? I only see the declarations. Try adding {} like this, if you don't define them elsewhere already.

Code: Select all

class DLL_EXPORT ILoadedMesh : public IBaseMesh
{
public:
   ILoadedMesh(IManager* mgr,const c8* file) {}
   virtual ~ILoadedMesh() {}
};
Also, be sure to make the IBaseMesh destructor virtual, if not done so already. This has nothing to do with this, but if you don't do this, you get unexpected behaviour when you delete an instance using a IBaseMesh or ILoadedMesh pointer.
Post Reply