SDL2_image linking errors

Hi, I’m new to SDL. I needed to be able to program for a mobile platform, so after doing some Windows stuff in SFML I thought I would try out SDL.

I attempted to include/link the library like usual. Using 32-bit for SDL2 and SDL2_image. SDL2 works fine, using the sample code provided by LazyFoo on his first SDL2 lesson it compiles, links, and executes with no errors.

Then I include and link SDL2_image, no problem: until I get LazyFoo’s Lesson 6 sample file.

The linker then complains about an ‘undefined reference’ for ‘IMG_Init’, ‘IMG_Quit’, and ‘IMG_Load’.

I know there are a ton of post like this, but I’ve tried alot of fixes and nothing seems to be working. I wondered if it might have to do with my MinGW version - I’m using CodeBlocks 13.12 (LazyFoo is using 12.11 I think), and though I don’t know the MinGW version off the top of my head, I’ve had problems like this before that IIRC had something to do with this.

My includes for the compiler are fine, so I’ll just include my linker settings. These are under Project>Build Options>Linker Settings>Other Linker Options

Code:
-lmingw32 -lSDL2main -lSDL2 -lSDL2_image

Not compiling from source, using precompiled dev libs, on Windows 7 x64, CodeBlocks 13.12; SDL 2.0.3 which works fine, SDL2_image which is found by the compiler and linker but gives undefined reference errors.

Thanks in advance for any assistance you can give. Please let me know if you need any info from me!

A bunch of people have seen this, does somebody need more info? I really have no idea what to do…

If it helps, ‘Android Bits’ thread explains linking issues with all Friend
Libs for Mobile, among other Bits ;-).

Do you have libSDL2_image in the lib search path (not really what it’s called in Code::Block) ?

Also, try compile+link on MSYS command line (if you have one installed). Sometimes the IDE is at fault.

One more thing to try is to compile SDL2_image yourself.

@mr_tawan: Yes, I know what you mean. SDL2_image libs are in the correct location. I do not have a MSYS command line, but I was thinking I would try compiling the lib myself. Will try that and post back here.

I have read somewhere that on MINGW, the order of -l parameter has some requirement that if there are one library depends on another, it should be in the list before the library it’s depended on. You might want to try putting -lSDL2_image before -lSDL2.

Modified the order of -l parameters. Still no dice. Tried moving all DLL’s to the project’s folder, got following error:

“The procedure entry point SDL_acosf could not be located in the dynamic link library [bla]\SDL2_image.dll”

The f is wrong with SDL_image?

I think that you should check the syntax of your code eg.
instead of
#include <SDL2/SDL2_image>
you put
#include <SDL2/SDL_imag>