'Stbi loading errors

When I try to use stbi to load an image all I get is this error:

1>Renderer.obj : error LNK2005: "void __cdecl stbi__unpremultiply_on_load_thread(int)" (?stbi__unpremultiply_on_load_thread@@YAXH@Z) already defined in LoadFile.obj

1>Main.obj : error LNK2005: "void __cdecl stbi__unpremultiply_on_load_thread(int)" (?stbi__unpremultiply_on_load_thread@@YAXH@Z) already defined in LoadFile.obj

1>Shape.obj : error LNK2005: "void __cdecl stbi__unpremultiply_on_load_thread(int)" (?stbi__unpremultiply_on_load_thread@@YAXH@Z) already defined in LoadFile.obj

1>Texture.obj : error LNK2005: "void __cdecl stbi__unpremultiply_on_load_thread(int)" (?stbi__unpremultiply_on_load_thread@@YAXH@Z) already defined in LoadFile.obj

and I get about 180 of these errors for different functions.

I include the stbi in one header file and I use this define

#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>


Solution 1:[1]

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

Put this in stb_image.cpp

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pedro_bb7