IMG_Load not referenced

My IMG_Load on CLion (MacOS) isn’t working. Keep getting the same linker error of
Undefined symbols for architecture x86_64:
“_IMG_Load”, referenced from:
Graphics::loadImage(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in graphics.cpp.o
ld: symbol(s) not found for architecture x86_64

I used brew to install sdl2_image and sdl2

Here is the code:

SDL_Surface* Graphics::loadImage(const std::string & filePath) {
    if (this->_spriteSheets.count(filePath) == 0){
        this->_spriteSheets[filePath] = IMG_Load(filePath.c_str());

    return this->_spriteSheets[filePath];


sounds like you’re not linking against SDL_Image (if you’re building on the commandline, pass -lSDL2_image to your compiler when linking)

What if you don’t use command line to build, I use the CLion ide and I just press debug.

I don’t know - somehow you have to configure how your application is built - what include directories the compiler is supposed to use and what libraries it’s supposed to link against.
I guess you configured it to link against libSDL2 already - you gotta do the same for libSDL2_image

I followed this blog in order to install SDL2 and SD2_image. I used Brew to install both.

My cmake files look exactly like that so I’m not sure what’s going on sadly.