3

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)

Luft
  • 185
  • 4
  • 17
  • 2
    Have you actually installed the SDL_image library? Where is the library file (libSDL_image.a) located? – davmac Jan 08 '15 at 00:33
  • 1
    I just did a search and I do not even 'have' libSDL_image.a, so it's apparent that I've not properly (or at all) installed it. (I got everything I have currently from https://www.libsdl.org/projects/SDL_image/) – Luft Jan 08 '15 at 01:23
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Captain Obvlious Jul 01 '15 at 19:59
  • I solved this because it tunerd out you also need to add -lSDL2_image when compiling.. just like it was suggested in the picture. thanks! – moldovean Oct 19 '15 at 10:52

3 Answers3

3

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.

davmac
  • 20,150
  • 1
  • 40
  • 68
2

I've had this problem in linux. the solution is simple. add to linker:

-lSDL2_image -g `sdl2-config --cflags --libs`

project build otpions, switches added to Other linker options

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

I had the same problem, and the solution was to include the SDL2main library in linker parameters.

For Dev-C++ IDE you can follow the instructions below:

Get SDL or SDL2 working correctly with Dev-C++

omotto
  • 1,721
  • 19
  • 20