I've downloaded stb_image.h (https://github.com/nothings/stb) and included in the .cpp file I want to use it.
Then I use the function to load an image
image_data = stbi_load(fileNames[i], &image_width, &image_height, &image_pixel_components, 0);
When I try to run the code in Visual Studio I get an error:
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
The answer is right at the top of stb_image.h:
Do this:
#define STB_IMAGE_IMPLEMENTATION
before you include this file in one C or C++ file to create the implementation.
i.e. it should look like this:#include .... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h"
Without this define, you will get errors about unresolved external symbols.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With