Archived

This topic is now archived and is closed to further replies.

Al MacInnis

C++, SDL & SDL_image Link problem [RESOLVED]

Recommended Posts

I am working on a SDL program, and there are no problems. Yesterday, i included the SDL_image library in order to load PNG, JPG... images in my program. I put the #include <SDL_image.h> as required. Compilation , no problems. Link : Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland Error: Unresolved external '_IMG_Load' referenced from C:\PROGRAMMATION\C++\SDL\SPRITES.OBJ I am using the IMG_load (char *file) function... Where am i wrong ? Did i forgot a file in the linker command line ? Thank you. "Everyday above ground is a good day" (Mel in Scarface) Edited by - Al MacInnis on February 21, 2002 1:22:44 PM [edited by - Al MacInnis on August 16, 2002 12:51:21 PM]

Share this post


Link to post
Share on other sites

I put zlib.dll libpng1.dll and SDL_image.dll in the Lib directory.
With implib, i created the .lib associated, and i put them in the command line of the linker, i get the same error

Share this post


Link to post
Share on other sites
Are we talking about SDL (Simple DirectMedia Layer)? If so, I''ve never seen IMG_load. Do you mean SDL_LoadBMP(const char *file)?? Anyway, you only have to include "SDL.h" to use it and that''s it.

Share this post


Link to post
Share on other sites
He is using SDL, but with the SDL_image library.

Are you sure you downloaded the right source? I know if you try to compile vc++ libraries with dev-c++ it won''t work. You have to download the mingw32 developer source. To get SDL to compile I have to link with

-lmingw32 -lSDLmain -lSDL

(and then don''t forget to link SDL_image)

Then I just check do not make a console. (I think the flag is -mwindows but i''m not sure)

Share this post


Link to post
Share on other sites
I am using Borland''s free compilers, and i downloaded (at least i think) the rioght components (for Win32 non VC++, there are no multiple choices )

here is the command line that makes the error :


ilink32 -aa -Tpe -L"c:\Programmation\Compil~1\Lib" %P%N.obj import32.lib SDL_image.lib sdl.lib zlib.lib libpng1.lib c0w32.obj cw32.lib

I added SDL_image.lib zlib.lib, libpng1.lib in the command line, since my programs without SDL_image (which run very fine).

Where is the problem :''( ?

"Everyday above ground is a good day" (Mel in Scarface)

Share this post


Link to post
Share on other sites
When I compile SDL on windows with dev-c++ I need to link with -lmingw32 -lSDLmain -lSDL

If you are getting an error with the name of a function in SDL_image, it means you did not link all the required libraries.

Share this post


Link to post
Share on other sites
yes this is probably a library that I don''t link but the problem is i put this "SDL_image.lib" (made from SDL_image.dll (taken on SDL_image site) with Borland''s implib)..
So i dont know where is the problem, i still get this _IMG_Load unreferenced.

"Everyday above ground is a good day" (Mel in Scarface)

Share this post


Link to post
Share on other sites
Implib is a Borland''s tool to generate a .lib file from a .dll file. I only found the SDL_image.dll in sdllib.org so i created SDL_image.lib. I saw this procedure in a SDL website.

"Everyday above ground is a good day" (Mel in Scarface)

Share this post


Link to post
Share on other sites
Maybe it is the order in which you link that causes the problem. Have you tried swapping SDL_image.lib and SDL.lib, or any other configuration of lib files.....

Share this post


Link to post
Share on other sites
Post on the SDL mailing list. They will probably be able to help you. Better still, search the mailing list first. Enter something like "borland linking site:libsdl.org" into Google, perhaps.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
Thank you everyone, I finally found what was wrong...
It was only a mis-creation of the .lib from the sdl_image.dll, I forgot 2 parameters using implib (-a -c). Thanks again all and sorry for the bothering

"Everyday above ground is a good day" (Mel in Scarface)

Share this post


Link to post
Share on other sites
Soy Chileno y no se mucho de inglés, la persona que sepa español sabrá solucionar el problema con SDL_image (IMG_Load()
Yo compilo con Dev-C++ y al crear un nuevo proyecto se debe editar las opciones de éste. Una vez hecho ésto se van a Parámetros->Linker->Add Library or Object , seleccionan SDL_image.lib , y LISTO !!!! compilation success o como se escriba

Share this post


Link to post
Share on other sites