2014-12-06 93 views
-4

我想尝试自己在一个小小的C++应用程序,但我总是得到LNK2001错误,我不知道我做错了什么。C++ - LNK2001错误

有人可以帮我吗?

#ifndef CONTENTMANAGER_H 
    #define CONTENTMANAGER_H 

    #include "SFML\Graphics.hpp" 
    #include <map> 
    #include <sstream> 

    using namespace sf; 
    using namespace std; 


    static class CONTENTMANAGER 
    { 
    public: 
      static Texture getTexture(string textureName) 
      { 
        if(textureMap.find(textureName) == textureMap.end()) 
        { 

            Texture texture; 
            stringstream ss; 
            ss<<"Texture"<<textureName<<".png"; 
            texture.loadFromFile(ss.str()); 
            textureMap.emplace(textureName, texture); 
            return textureMap[textureName]; 

        } 
        else 
        { 
          return textureMap[textureName]; 
        } 
      } 

    private: 
      static map<string,Texture> textureMap; 
    }; 




    #endif 

ERRORMESSAGE:http://www.bilderhoster.net/safeforbilder/5mdt1tzc.png

+0

你在使用什么操作系统?你在编译什么?什么是完整的错误信息? – 2014-12-06 22:05:33

+0

这将有助于查看完整的错误消息。很可能你没有编译与你的项目一起的'Texture'类函数调用的代码和/或没有正确地链接包含这些定义的库文件。 – Amadeus 2014-12-06 22:06:10

+0

我已将我的错误消息加入我的文章 – 2014-12-06 22:11:13

回答

0

它是在错误的messge大量的行李一个简单的错误!

您尚未定义名为'textureMap'的静态成员变量。链接时,您实际上正在获取未定义的符号错误。

在.cpp文件中,请定义该变量。这应该照顾你的问题。

相关问题