Search code examples
visual-c++compiler-errorslinker-errorslnk2019

error LNK2019: unresolved external symbol/


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.


Solution

  • 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