Polytonic/Glitter

stbi load not working on macOS, linker problems

drs-m opened this issue · 4 comments

drs-m commented

trying to use 'stbi_load' does not work in CLion on MacOS. did a fresh clone of master. include_directories contains the stb Vendor folder.

Undefined symbols for architecture x86_64:
"_stbi_image_free", referenced from:
_main in main.cpp.o
"_stbi_load", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Hmm, I've never tried using CLion. Does it compile if you use a standard makefile?

#32
this is the way to solve the problem.
// Reference: https://github.com/nothings/stb/blob/master/stb_image.h#L4
// To use stb_image, add this in one C++ source file.
// #define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

=====
// add these in your "main.cpp" C++ source file
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

did you find a solution?

That was the solution...