2014-12-06 98 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文件中,請定義該變量。這應該照顧你的問題。

相關問題