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!
@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.