Public Group

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi.. I'm currently reading the Lazy Foo productions tutorial on SDL and can't get it to work, the image extension library that is. I've extracted the necessary lib files, dll files and the include file to the right folders. I've also extracted all the dll files into the system32 folder, i'm using the paramter -ISDL_image and yes I have the other parameters too (-lmingw32 -lSDLmain -lSDL). I don't get any compiler errors, but a linker error which is the following: undefined reference to IMG_Load' I'm using dev c++ and this is the only code block that use IMG_Load.
[SOURCE]
SDL_Surface *load_image(std::string filename) {
//Temporary storage for the image that's loaded
SDL_Surface* loadedImage = NULL;

//The optimized image that will be used
SDL_Surface* optimizedImage = NULL;

//If nothing went wrong in loading the image
if (loadedImage != NULL) {
//Create an optimized image

//Free the old image
}

return optimizedImage;
}
[/SOURCE]
I have searched around everywhere but haven't found anything that could help me, thankful for help..

##### Share on other sites
Well, you also need to link the SDL_Image, that is,
-lSDL_Image
(note: that is a little el, not a big ai)

##### Share on other sites
Like I said, i've already linked to that, do you know any other reason it could be like this?

##### Share on other sites
You could try rearranging the order of your linked libs. That makes a difference for MinGW I think.

Sorry I can't be more specific.

##### Share on other sites
Quote:
 Original post by Simian ManYou could try rearranging the order of your linked libs. That makes a difference for MinGW I think.Sorry I can't be more specific.

The perfect order is:
-lmingw32-lSDLmain[other sdl libs]-lSDL[if you have any opengl stuff]

Atleast it works for me :).

##### Share on other sites
This is the complete parameter list in order i'm using:
-lmingw32 -lSDLmain -lSDL -ISDL_Image

prog.cpp: undefined reference to IMG_Load'

This is really frustruating, can't continue reading if it doesn't become right. It's only one function and that is IMG_Load, I hate illogical errors like these that should be right, but are filled with errors even so.

Well, anyways, if someone knows anything about this, please post here, will search around some more about it.

##### Share on other sites
Sharlin already told you the solution!

use
-lSDL_Image
-ISDL_Image

(have a closer look at the first character before "SDL_Image"....)

##### Share on other sites
Ok, to elaborate:

* The -Idirectory (big ai) argument tells the compiler to search for header files from that directory in addition to the default ones.

* But the -llibrary (little ell) argument, instead, tells the linker to link the given library to the executable.

In this case, you need both of those arguments for the compiling to succeed.

##### Share on other sites
Quote:
 Original post by SharlinOk, to elaborate: * The -Idirectory (big ai) argument tells the compiler to search for header files from that directory in addition to the default ones. * But the -llibrary (little ell) argument, instead, tells the linker to link the given library to the executable. In this case, you need both of those arguments for the compiling to succeed.

I didn't.

##### Share on other sites
No really, the linker parameters should be like this:

-lmingw32
-lSDLmain
-lSDL
-lSDL_image

Notice the little L at the start in each case.
Also make sure you've extracted the bits of the image package appropriately..

SDL_image.lib from SDL_image-1.2.4/lib to Dev-Cpp/lib

1. 1
2. 2
3. 3
JoeJ
12
4. 4
5. 5

• 12
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632176
• Total Posts
3004588

×