c++symbolsstb-image

stbi_write_png external symbol not solved


I can use stbi_load correctly and have the next code in a .cpp file:

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

When trying to use stbi_write_png I got a compiling error saying thats unsolved symbol. This is the code where I call the function.

void FeatherGUI::saveImage() {
    //save the current image using stb write
    stbi_write_png(this->CurrentImage->name.c_str(), this->CurrentImage->width, this->CurrentImage->height, this->CurrentImage->channels, this->CurrentImage->data, this->CurrentImage->width * this->CurrentImage->channels);
}

What can I do?


Solution

  • Adding

    #define STBI_MSC_SECURE_CRT
    #define STB_IMAGE_WRITE_IMPLEMENTATION
    #include "stb_image_write.h"
    

    Fixed the problem also has to change the sprintf call inside the stb_image_write to sprintf_s.