-1

I'm having a lot of trouble trying to compile an ogre sample found on Github.

I've had several Intellisense errors, compilation & linking errors. Now I'm stuck with 2 linker errors. I know there's a lot of similar questions around here because I've read a lot on the subject but I can't find (or see) the right solution.

error LNK2019: unresolved external symbol "public: __thiscall NFSpace::PlanetMapTile::PlanetMapTile(struct NFSpace::QuadTreeNode *,class Ogre::SharedPtr<class Ogre::Texture>,class Ogre::Image,class Ogre::SharedPtr<class Ogre::Texture>,int)" (??0PlanetMapTile@NFSpace@@QAE@PAUQuadTreeNode@1@V?$SharedPtr@VTexture@Ogre@@@Ogre@@VImage@4@1H@Z) referenced in function "public: class NFSpace::PlanetMapTile * __thiscall NFSpace::PlanetMap::finalizeTile(struct NFSpace::QuadTreeNode *)" (?finalizeTile@PlanetMap@NFSpace@@QAEPAVPlanetMapTile@2@PAUQuadTreeNode@2@@Z)  

error LNK2019: unresolved external symbol "public: struct NFSpace::QuadTreeNode const * __thiscall NFSpace::PlanetMapTile::getNode(void)" (?getNode@PlanetMapTile@NFSpace@@QAEPBUQuadTreeNode@2@XZ) referenced in function "public: void __thiscall NFSpace::PlanetRenderable::setFrameOfReference(struct NFSpace::PlanetLODConfiguration &)" (?setFrameOfReference@PlanetRenderable@NFSpace@@QAEXAAUPlanetLODConfiguration@2@@Z) 

here is the code associated with the first error:

PlanetMapTile.h

namespace NFSpace {

class PlanetMapTile {  

public:
PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size);
~PlanetMapTile();
};
} 

PlanetMapTile.cpp

#include "PlanetMapTile.h"

namespace NFSpace {

PlanetMapTile::PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size) {     
//do something
}

PlanetMapTile::~PlanetMapTile() {
//do something
}
}

PlanetMap.h

#include "PlanetMapTile.h"  

namespace NFSpace {

class PlanetMap {
public:
PlanetMapTile* finalizeTile(QuadTreeNode* node);  
};
}

PlanetMap.cpp

 #include "PlanetMap.h"

 namespace NFSpace {

 PlanetMapTile* PlanetMap::finalizeTile(QuadTreeNode* node) {
    mStep = 0;
    return new PlanetMapTile(node, mHeightTexture, mHeightImage, mNormalTexture, getInt("planet.textureSize"));
}
}

Any help would be appreciated.

7
  • 1
    Is PlanetMapTile.cpp getting compiled? Jul 21, 2014 at 10:41
  • Also, where is getNode declared/defined? Jul 21, 2014 at 10:42
  • Is your class, declared in PlaneTitleMap.h inside your NFSpace namespace?
    – YePhIcK
    Jul 21, 2014 at 10:44
  • @ Luchian Grigore Yes I have all the obj files right. The problems arise whith the linker
    – Georges S.
    Jul 21, 2014 at 10:45
  • This code doesn't compile. namespace NFSpace is missing a closing brace, and class PlanetMap is missing a closing semicolon.
    – TonyK
    Jul 21, 2014 at 11:02

2 Answers 2

0

That is how you should declare the name space

PlanetMApTile.h

namespace NFSpace{
class PlanetMapTile {  

public:
PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size);
~PlanetMapTile();
};  
}

PlanetMapTile.cpp

#include "PlanetMapTile.h"
NFSpace::PlanetMapTile::PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size) {     
//do something
}

NFSpace::PlanetMapTile::~PlanetMapTile() {
//do something
}

PlanetMap.h

#include "PlanetMapTile.h"  

class PlanetMap {
public:
NFSpace::PlanetMapTile* finalizeTile(QuadTreeNode* node);  
}

PlanetMap.cpp

#include "PlanetMap.h"

NFSpace::PlanetMapTile* PlanetMap::finalizeTile(QuadTreeNode* node) {
    mStep = 0;
    return new NFSpace::PlanetMapTile(node, mHeightTexture, mHeightImage, mNormalTexture, getInt("planet.textureSize"));
}
9
  • It's completely OK, to have a using statement, or wrap the function definitions inside a namespace block in the translation unit. Jul 21, 2014 at 10:51
  • forgot to add the namespace NFSpace in my question but it's there in PlanetMApTile.h. I'll try NFSpace::PlanetMapTile::PlanetMapTile
    – Georges S.
    Jul 21, 2014 at 10:53
  • @πάντα ῥεῖ of course you could use "using" I tend not to use it as i like to be explicit when coding
    – okaerin
    Jul 21, 2014 at 10:55
  • @GeorgesS. could you be more specific ? In my opinion it should work like this just fine
    – okaerin
    Jul 21, 2014 at 10:56
  • @thebaconing I'm trying what you suggest but I still get the error
    – Georges S.
    Jul 21, 2014 at 11:09
0

So I've finally found the solution:

Considering the fact that PlanetMapTile() and getNode() were both involving QuadTreeNode* and that ~PlanetMapTile() didn't raise an error, I've started to look at the QuadTreeNode declaration which is located in PlanetCubeTree.h. Then I've just tried to add #include "PlanetCubeTree.h" to PlanetMapTile.h and it solved the error.

Thank you for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.