C++ Visual Studio中的stb_image.h-未解析的外部符号
我已经下载了stb_image.h(),并包含在.cpp文件中,我想使用它 然后我使用函数加载一个图像C++ Visual Studio中的stb_image.h-未解析的外部符号,c++,visual-studio-2012,compiler-errors,C++,Visual Studio 2012,Compiler Errors,我已经下载了stb_image.h(),并包含在.cpp文件中,我想使用它 然后我使用函数加载一个图像 image_data = stbi_load(fileNames[i], &image_width, &image_height, &image_pixel_components, 0); 尝试在Visual Studio中运行代码时,出现错误: Error 3 error LNK2019: unresolved external symbol _stbi_l
image_data = stbi_load(fileNames[i], &image_width, &image_height, &image_pixel_components, 0);
尝试在Visual Studio中运行代码时,出现错误:
Error 3 error LNK2019: unresolved external symbol _stbi_load referenced in function "public: bool __thiscall CubemapTexture::Load(void)" (?Load@CubemapTexture@@QAE_NXZ) ...\CubemapTexture.obj
Error 40 error LNK2001: unresolved external symbol _stbi_load ...\Texture.obj
答案就在下面的顶部: 这样做:
#define STB_IMAGE_IMPLEMENTATION
在将该文件包含在一个C或C++文件中以创建实现之前。 i、 e.它应该是这样的:
#include ....
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
如果没有此定义,您将获得有关未解析外部符号的错误