Visual c++ 错误LNK2019:未解析的外部符号/

Visual c++ 错误LNK2019:未解析的外部符号/,visual-c++,compiler-errors,linker-errors,lnk2019,Visual C++,Compiler Errors,Linker Errors,Lnk2019,我在编译Github上的食人魔示例时遇到了很多麻烦 我有几个Intellisense错误,编译和链接错误。现在我遇到了两个链接器错误。我知道这里有很多类似的问题,因为我读了很多关于这个主题的书,但我找不到(或看到)正确的解决方案 error LNK2019: unresolved external symbol "public: __thiscall NFSpace::PlanetMapTile::PlanetMapTile(struct NFSpace::QuadTreeNode *,clas

我在编译Github上的食人魔示例时遇到了很多麻烦

我有几个Intellisense错误,编译和链接错误。现在我遇到了两个链接器错误。我知道这里有很多类似的问题,因为我读了很多关于这个主题的书,但我找不到(或看到)正确的解决方案

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) 
PlanetMatiple.cpp

#include "PlanetMapTile.h"

namespace NFSpace {

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

PlanetMapTile::~PlanetMapTile() {
//do something
}
}
 #include "PlanetMap.h"

 namespace NFSpace {

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

namespace NFSpace {

class PlanetMapTile {  

public:
PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size);
~PlanetMapTile();
};
} 
#include "PlanetMapTile.h"  

namespace NFSpace {

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

#include "PlanetMapTile.h"

namespace NFSpace {

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

PlanetMapTile::~PlanetMapTile() {
//do something
}
}
 #include "PlanetMap.h"

 namespace NFSpace {

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

任何帮助都将不胜感激。

这是您应该如何声明名称空间的

PlanetMatiple.h

namespace NFSpace{
class PlanetMapTile {  

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

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

NFSpace::PlanetMapTile::~PlanetMapTile() {
//do something
}
#include "PlanetMap.h"

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

#include "PlanetMapTile.h"  

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

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

NFSpace::PlanetMapTile::~PlanetMapTile() {
//do something
}
#include "PlanetMap.h"

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

所以我终于找到了解决办法:

考虑到
planetmatile()
getNode()
都涉及
QuadTreeNode*
,并且
~planetmatile()
没有引发错误,我开始研究
QuadTreeNode
声明,它位于PlanetCubeTree.h中。然后我刚刚尝试将
#include“PlanetCubeTree.h”
添加到planetmatile.h,它解决了错误


感谢您的帮助

PlanetMatile.cpp是否正在编译?另外,getNode在哪里声明/定义?您的类是否在
PlanetTitleMap.h
中声明,位于
NFSpace
命名空间中?@Luchian Grigore是的,我所有的obj文件都正确。如果链接器未编译,则会出现问题
namespace
缺少右大括号,
class PlanetMap
缺少右分号。使用语句创建一个
,完全可以,或者将函数定义包装在翻译单元中的
名称空间
块中。在我的问题中忘记添加
名称空间
,但它在planetmatile.h中。我将尝试
NFSpace::planetmatile::planetmatile
@πάνταῥεῖ 当然,你可以用“using”,我倾向于不使用它,因为我喜欢在coding@GeorgesS. 你能说得更具体些吗?在我看来,应该是这样的fine@thebaconing我在试你的建议,但我还是有错误