Sign in to follow this  
Calin

initialize the base

Recommended Posts

Calin    419
I'm trying to move a constructor definition from the header to cpp and I can't get it work When contained in header the class compiles fine.
deck::deck(irr::scene::ISceneNode* parent,
		   irr::scene::ISceneManager* mgr,
		   irr::s32 id, bool test): irr::scene::ISceneNode(parent, mgr, id)
	{
		//things
	}

//after split

//.h
deck(irr::scene::ISceneNode* parent,
		   irr::scene::ISceneManager* mgr,
		   irr::s32 id, bool test);

//.cpp
deck::deck(irr::scene::ISceneNode *parent,
		   irr::scene::ISceneManager *mgr,
		   irr::s32 id, bool test) :  irr::scene::ISceneNode(parent, mgr, id)
{
		//things
}

//after splitting I get a lot of linker cussing. 
deck.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const deck::`vftable'{for `irr::io::IAttributeExchangingObject'}" (__imp_??_7deck@@6BIAttributeExchangingObject@io@irr@@@) referenced in function "public: __thiscall deck::deck(class irr::scene::ISceneNode *,class irr::scene::ISceneManager *,int,bool)" (??0deck@@QAE@PAVISceneNode@scene@irr@@PAVISceneManager@23@H_N@Z)
deck.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const deck::`vftable'{for `irr::IReferenceCounted'}" (__imp_??_7deck@@6BIReferenceCounted@irr@@@) referenced in function "public: __thiscall deck::deck(class irr::scene::ISceneNode *,class irr::scene::ISceneManager *,int,bool)" (??0deck@@QAE@PAVISceneNode@scene@irr@@PAVISceneManager@23@H_N@Z)
deck.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const deck::`vftable'" (__imp_??_7deck@@6B@) referenced in function "public: __thiscall deck::deck(class irr::scene::ISceneNode *,class irr::scene::ISceneManager *,int,bool)" (??0deck@@QAE@PAVISceneNode@scene@irr@@PAVISceneManager@23@H_N@Z)
deck.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const deck::`vbtable'{for `irr::io::IAttributeExchangingObject'}" (__imp_??_8deck@@7BIAttributeExchangingObject@io@irr@@@) referenced in function "public: __thiscall deck::deck(class irr::scene::ISceneNode *,class irr::scene::ISceneManager *,int,bool)" (??0deck@@QAE@PAVISceneNode@scene@irr@@PAVISceneManager@23@H_N@Z)
deck.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const deck::`vbtable'{for `irr::scene::ISceneNode'}" (__imp_??_8deck@@7BISceneNode@scene@irr@@@) referenced in function "public: __thiscall deck::deck(class irr::scene::ISceneNode *,class irr::scene::ISceneManager *,int,bool)" (??0deck@@QAE@PAVISceneNode@scene@irr@@PAVISceneManager@23@H_N@Z)




[Edited by - Calin on June 24, 2009 6:40:15 AM]

Share this post


Link to post
Share on other sites
Captain P    1092
The code you've posted is very minimalistic. Can you provide some more of the surrounding code? Like, say, the full .h and .cpp files? You've probably forgotten some detail, which is hard to tell without the full code.

Share this post


Link to post
Share on other sites
Calin    419
this is the class


class deck : public irr::scene::ISceneNode
{


irr::core::aabbox3d<irr::f32> Box;
irr::video::S3DVertex Vertices[4096];
irr::u16 indices[16000];
irr::video::SMaterial Material;
faces Geometry;
int VCount;
int FCount;



public:


void FillSquare(int x, int y, int z,bool Done);


void Load()
{

int x;
int y;
int z;

Geometry.GeometryCount(VCount,FCount);
for(int i =0;i < VCount;i++)
{
Geometry.VertexData(i,x,y,z);
Vertices[i] = irr::video::S3DVertex(x*20,y*20,z*20, 0,1,0,
irr::video::SColor(100,100,(int)255/y,0), 0, 1);
}
int f1;
int f2;
int f3;
for(int i =0; i<FCount;i++)
{
Geometry.FaceData(i,f1,f2,f3);
indices[i * 3 + 0] = f1;
indices[i * 3 + 1] = f2;
indices[i * 3 + 2] = f3;

}




Box.reset(Vertices[0].Pos);
for (irr::s32 i=1; i<VCount; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}



deck(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id)
: irr::scene::ISceneNode(parent, mgr, id)
{
Material.Wireframe = false;
Material.Lighting = false;
Geometry.Reset();
}


virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);

ISceneNode::OnRegisterSceneNode();
}


virtual void render()
{

irr::video::IVideoDriver* driver = SceneManager->getVideoDriver();

driver->setMaterial(Material);
driver->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0],VCount, &indices[0], FCount);

}


virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const
{
return Box;
}

virtual irr::u32 getMaterialCount() const
{
return 1;
}

virtual irr::video::SMaterial& getMaterial(irr::u32 i)
{
return Material;
}
};


Share this post


Link to post
Share on other sites
Calin    419
yes, I didn't include the export lines.

Quote:

/*
#ifdef _DECK
#define DECKC __declspec(dllexport)
#else
#define DECKC __declspec(dllimport)
#endif
*/

class /* DECKC */deck : public irr::scene::ISceneNode
{

Share this post


Link to post
Share on other sites
Evil Steve    2017
Are all your classes used in the DLL also exported as __declspec(dllexport)? In particular, all base classes of deck.

As an aside - this is why exporting classes from DLLs is a mess and extremely unportable in C++...

Share this post


Link to post
Share on other sites
Calin    419
I usually do 1 exported class per dll. In this case it's a class that inherits (a class from) irrlicht and contains a class object (faces Geometry). The dll doesn't have anything else but this class

Share this post


Link to post
Share on other sites
Calin    419
Quote:
Original post by Zahlman
Does this help?


I've seen you pointing at that in your earlier posts. I guess the problem is I don t know how to make the split of all those functions, the sintax makes me faint.

[Edited by - Calin on June 27, 2009 10:13:39 PM]

Share this post


Link to post
Share on other sites

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