I want to load images using stb_image. I downloaded stb_image.h
from https://github.com/nothings/stb. When I run the code:
string file="image.png";
int width,height,components;
unsigned char *imageData = stbi_load(file.c_str(),
&width, &height, &components, STBI_rgb_alpha);
i get the following errors:
Main.cpp:(.text+0xa14): undefined reference to `stbi_load'
Main.cpp:(.text+0xb74): undefined reference to `stbi_image_free'
You probably should add: #define STB_IMAGE_IMPLEMENTATION
to your code before the include. This is suggested in one of the first lines of the header file.
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