Search code examples
c++referenceg++mingwsdl

MinGW "undefined reference to IMG_Load/IMG_Init/IMG_Quit" LazyFoo


I am going off of LazyFoo's SDL2 tutorials for C++ using the MinGW g++ compiler (using console). I have followed his page here, step-for-step. I have finally come across this error after having downloaded his example.

enter image description here

I have seen plenty of people online struggle with SDL_Image, but I've not yet seen this and I haven't found any solution to it yet.

  • I've loaded the include and lib folders with the proper assets
  • I've copied all necessary .dll's to my compile destination
  • The example LazyFoo provides includes for SDL_Image and SDL itself

(this question my sound redundant, but I've yet to come across a solution that applies to console-compilation)


Solution

  • Based on the comments above, the answer seems to be:

    You need to install the development libraries for SDL_image.

    You can download them here: https://www.libsdl.org/projects/SDL_image/ (look under the heading "Development libraries").

    You need to ensure the path where the libSDL2_image.a file resides is in the linker search path. One way of doing this is to add an appropriate -L parameter to the link command. You could also drop the file in the default library search path.