5

I'm learning SDL through Lazy Foo's tutorial, but I can't proceed further as IMG_Load doesn't seem to work. I tried setting it up like he says, but it just doesn't work. I put all the include files into include folder, and all the lib files into the lib folder. What I found is that there were x86 and x64 folders in the lib folder. When I tried x64 (because I have a 64-bit system)it all worked fine, CodeBlocks even told me suggestions (like when I wrote "img" it showed up a suggestion "IMG_Load" (which means the library got initalized?)), but when I come to compiling my code, this happens: http://puu.sh/3Eqa5.png. When I try with the x86 version, exact same error.

I had a little search around the internet, and all I could find were a few threads, but most of them were abandoned. The closest I got to answering my problem was this: http://www.dreamincode.net/forums/topic/118299-sdl-image-error-sdl/ but the guy solved his problem by downloading a problem which Linux can use, not Windows. }

I'm running Windows 7 64-bit, CodeBlocks 12.11, SDL 1.2.15 and SDL_Image 1.2.12.

I really don't know what the problem is!

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Add the command Codeblock is using to compile your project to your question. – greatwolf Jul 20 '13 at 01:37
  • possible duplicate of [How do I set up additional SDL libraries in CodeBlocks?](http://stackoverflow.com/questions/17684421/how-do-i-set-up-additional-sdl-libraries-in-codeblocks) – greatwolf Jul 20 '13 at 01:39

3 Answers3

4

In addition to the @Aleeee's answer, a command line solution is to add -lSDL2_image compiler flag (SDL2 is the up-to-date version by the time of this writing).

Compilation example:

gcc -o object_file_name source_file_name.c `sdl2-config --cflags --libs` -lSDL2_image
Onik
  • 19,396
  • 14
  • 68
  • 91
3

You should go to the Compiler and Debugger settings again and under the Linker Settings tab paste: -lSDL_image enter image description here

Aleeee
  • 1,913
  • 6
  • 17
  • 27
0

It turns out the SDL_Image library I was using was buggy. I don't know how that happened though. I just had to use a older version. Thanks to anyone who helped!