Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Visual Studio中的stb_image.h-未解析的外部符号_C++_Visual Studio 2012_Compiler Errors - Fatal编程技术网

C++ Visual Studio中的stb_image.h-未解析的外部符号

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

我已经下载了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_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"
如果没有此定义,您将获得有关未解析外部符号的错误