SDL IMG_Load

Started by
27 comments, last by password 18 years ago
I'm pretty sure I got it from here using the "SDL_image-devel-1.2.4-VC6.zip" file. It has SDL_image.lib; I don't remember if I renamed this file to libSDL_image.a or not but I definitely do have libSDL_image.a in my compiler's lib folder. I guess that's what I did.

Hey: I tried renaming libSDL_image.a to SDL_image.lib and I could still compile projects dependent on SDL_image fine! Either way you'll need the file if you don't have it, but it looks like renaming it is optional. I wonder why I did it originally?
It only takes one mistake to wake up dead the next morning.
Advertisement
Damn, it still doesn't work, why do these illogical errors keep bugging me wherever I go, they always appear where I am!

I've tried many things now, renamed the -lSDL_image parameter to these things:
-SDL_image
-SDL_image.lib
-lSDL_image.lib
-llibSDL_image.a
-libSDL_image.a
-lc:\dev\lib\SDL_image
-l\dev\lib\SDL_image

have also tried to rearrange the order countless times, with all those combinations aswell. It should find it, i've copied the file in every folder in dev-c++. It keeps saying that it doesn't find the file, these kind of errors seem to be unsolveable.
I don't think you answered a couple of the questions above:
- Do you have libSDL_image.a?
- If so, is it in the correct directory?
- And where did you get it from?

I don't think you can get away with just renaming a .lib as a .a file. One is for Microsoft compilers and one is not.
I originially thought that the differences between the library version (MSVC vs. MinGW) were your problem, but this says that it's a straight C library and the MinGW linker should be able to link against it.

I found this on the web about setting up SDL_image with MinGW at http://gpwiki.org/index.php/SDL:Tutorials:Setup

Quote:

MinGW and SDL_image


SDL_image is an invaluable add-on library that allows you to use a wide variety of image formats with SDL, including BMP, JPG, GIF, PNG, TGA, PCX and many more (as opposed to just BMPs with SDL alone).

If you want to get up and running quickly without re-compiling from source, simply grab the runtime development package. This time however, you can use the MSVC package. You can link directly to the SDL_image.lib file as it only requires plain vanilla C linkage (no C++ or other MinGW-specific WinMain). Just extract the archive to a location and remember to set the include and lib paths when you compile.

The documentation site for SDL_image is clear and straightforward. It also has an excellent example source to try which serves as a great little intro to both SDL and SDL_Image at the same time. Assuming your SDL/ and SDL_image/ directories are at the same level, create another folder at that same level, called viewimage. Grab the viewimage.c source from the demos directory, as well as a few image files to test. Put the files you download in the viewimage folder. Then you can use this makefile to build the test app:

make -f viewimage.makefile

MinIDE users will just build an SDL project as usual, but add the SDL_image.lib file to the project by dragging that file's icon into the target window, and adding ../SDL_image/include to the include path.

Finally, copy all the .dll files (zlib.dll, jpeg.dll, libpng1.dll, SDL_image.dll and SDL.dll) to the viewimage directory so the app can find them when you run it. The app is a command-line app, so pull up a command prompt and cd to that directory. Test it by running it with the name of one of the demo images:



Cheers,

Bob

[Edited by - Scourage on April 2, 2006 2:11:51 PM]

[size="3"]Halfway down the trail to Hell...
I have had similar troubles statically linking to SDL_image across various compilers. Since it is one dll/so with one (useful) entry point, I would recommend just loading it dynamically.

In SDL, something like this (I haven't compiled it):

void* handle = SDL_LoadObject( "SDL_image" );
libIMG_Load = (PFN_IMG_LOAD) SDL_LoadFunction( handle, "IMG_Load" );

will find the IMG_Load for you. You will have to put in some #ifdefs to load the correct filename: SDL_image, SDL_image.so, or SDL_image.dylib. But overall I find, for this case, a dynamic load easier to get working.

lee
Are you using the latest version of Dev C++?

older versions don't support *.lib files.

Learn to make games with my SDL 2 Tutorials

Here's a SDL_Image package for Dev-C++

https://sourceforge.net/project/showfiles.php?group_id=94270&package_id=141519&release_id=298331

This should work for you.

Cheers,

Bob

[size="3"]Halfway down the trail to Hell...
Ugh, nothing like GD going down during a long post [lol]

Step By Step Guide™

1. Start up DevCpp 4.9.9.2. If you do not have that version, then you will need to uninstall the current version you have and delete the folder it was in. Then proceede to SourceForge to download the current version and install it.


2. Next, go to Tools->Check For Updates/Packages. This option is a neat little functionality built into Dev-Cpp that allows you to download DevPaks. Think of a DevPak like an installation file that contains everything you need to use some 3rd party library. In otherwords, all of the hard work needed to using any library that has a DevPak for is already done [wink]


3. Once you click on that, you will get a new window. The first thing you will want to do is change the Mirror Site that you update from. Under the "Select devpak server", change it to "devpaks.org Community DevPaks"


4. Now click on the Check For Updates button in the bottom left corner. The program will connect to the internet and download the recent list of what is avaliable for you to download.


5. Now that you have a big list of libraries, it is time to find what you need! Scroll down and find the "SDL_Image" entry. There will be two, the one you are looking for says version "1.2.4notiff". Click once on the name, but do not add a check mark in the box. If you look at the "File Description", you will see that it says "Depends on SDL, libjpeg, zlib, and libpng". This means that you cannot install this DevPak until you have those other libraries.


6. You will now need to go ahead and find those libraries in the box, place check boxes for them, then download and install them. One thing that you should see though is that those libraries that you need to download might also have dependecies, so you will have to download and install them in a certain order was well.

Since this is your first time, you will want to download SDL first (if you are not using a SDL DevPak aleady that is), then libjpeg, zlib, then libpng in that order. When all updates are done downloading, you will get a little message box telling you and the installation process will start.


7. You just have to hit next a few times, then finish for each library. Sometimes the focus may be lost so check your task bar for the window to install if it does not come up to your screen automatically.


8. Now, once you have the secondary libraries donwloaded and installed, you can install SDL_Image and you are all done! For your project you just have use the necessary libraries. To do that, go to Project->Project Options. Under the Parameter tab, you will need to enter in libs:
-lmingw32
-lsdlmain
-lsdl
-lsdl_image
You have to link your libs in a specific order due to how some depend on others.


9. You will need to get libpng12.dll in order to use SDL_Image now, so download that dll here. Move that DLL into your current project's directory or your system32 directory.

10. Now you should have a working project. For a quick test project, you can use this little demo. (Don't forget to copy over your SDL.dll to the folder!)

That's all there is to it really. If you have trouble finding the DevPaks for a particular library in this example, look at this page. You will be able to download the DevPaks and dependecies manually.

You should be able to double click on the to install them. I was able to download the libjpeg DevPak earlier when I started writing this, but now that I check again, it seems to have disappeared, so you may have to manually download it if it does not come up for you either. If you run into any other problems, let us know, good luck!
Thank you for your answers, I didn't have the new dev cpp, I downloaded mine from the official homepage and was probably an old version.

I won't bother you anymore with this question now.

This topic is closed to new replies.

Advertisement