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

Georges S.
  • 35
  • 2
  • 7

2 Answers2

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"));
}
TonyK
  • 16,761
  • 4
  • 37
  • 72
okaerin
  • 789
  • 5
  • 23
  • It's completely OK, to have a `using` statement, or wrap the function definitions inside a `namespace` block in the translation unit. – πάντα ῥεῖ Jul 21 '14 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 '14 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 '14 at 10:55
  • @GeorgesS. could you be more specific ? In my opinion it should work like this just fine – okaerin Jul 21 '14 at 10:56
  • @thebaconing I'm trying what you suggest but I still get the error – Georges S. Jul 21 '14 at 11:09
  • @GeorgesS. Well it should work like this. as Hans Passant mentioned in the comments it is suspicious that the types get converted. I don't know how your project setup looks like or if you are really using the correct files. Thats what i would check if i were you – okaerin Jul 21 '14 at 12:32
  • @thebaconing There's `using namespace Ogre` in both header files, could it be related ? I really don't know what's left to check – Georges S. Jul 21 '14 at 12:53
  • @GeorgesS. that shouldn't make any difference. Is the compiler warning still the same after you applied my suggestion? – okaerin Jul 21 '14 at 12:55
  • @thebaconing the message is the same. – Georges S. Jul 22 '14 at 00:51
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

Georges S.
  • 35
  • 2
  • 7