C++ - LNK2001 error
C++ - LNK2001 error
我想尝试一下C++应用程序,但我总是收到LNK2001错误,我不知道我做错了什么。
有人可以帮我吗?
#ifndef CONTENTMANAGER_H
#define CONTENTMANAGER_H
#include "SFMLGraphics.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
错误消息:http://www.bilderhoster.net/safeforbilder/5mdt1tzc.png
这是一个简单的错误,错误混乱中有很多包袱!
您尚未定义名为"textureMap"的静态成员变量。您实际上在链接时收到未定义的符号错误。
在.cpp文件中,请定义该变量。这应该可以解决您的问题。
相关文章:
- "error: no matching function for call to"构造函数错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- C++错误:"error: int aaa::bbb is protected within this context"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 使用 cmake 的 LLVM 构建在 tsan_libdispatch_mac.cc 期间失败; "Error: conflicting types for ..."
- C++ "error: invalid use of void expression"
- struct.error:解压缩 C++ 结构时,解包需要 288 字节的缓冲区
- ERROR LNK2001 AND LNK2019
- "Error LNK2001: unresolved external symbol _main"仍然存在
- C++ OOP LNK2001 ERROR
- 我收到错误"LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup"
- C++ - LNK2001 error
- Visual Express 2012 C++ error LNK2001
- 将 Antlr 与 Visual Studio 集成时出现问题 C++ 2010 的 "error LNK2001: unresolved external symbol"
- error lnk2001: closedir, readdir, opendir
- error LNK2001 Visual C++
- 从 Visual Studio 2012 使用 GnuTLS 3.1.6 时获取"error LNK2001: unresolved external symbol _gnutls_free"