installing SDL_image problem

hi i m having problems for a few days. not sure what the porblem is and here is a pic to show you my installed sdl(in case problem is there)
http://postimg.org/image/uwaewwj75/

here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif

#include <SDL/SDL.h>
#include <string>
#include <SDL/SDL_image.h>

SDL_Surface* LoadedImage = NULL;
SDL_Surface* OptimizedImage = NULL;
SDL_Surface* bg = NULL;

SDL_Surface* LoadImage(std::string Path){
    LoadedImage = IMG_Load(Path.c_str());
    if(LoadedImage != NULL) {
        OptimizedImage = SDL_DisplayFormat( LoadedImage );
        SDL_FreeSurface( LoadedImage );
    }
    return OptimizedImage;
}

int main ( int argc, char** argv )
{
    bg = LoadImage("bg2.png");
    if(bg == NULL)return 1;

    return 0;
}


and the build log
-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"C:\Users\Ceset\Desktop\Game\SDL - 1.2.15 - 2.0.0\lib" -L"C:\SDL 1.2.12 - 2.0.0\lib"  -o bin\Debug\test.exe obj\Debug\main.o   -lmingw32 -lSDLmain -lSDL -lSDL2main -lSDL_image -lSDL2_image  -lmingw32 -lSDLmain -lSDL.dll -luser32 -lgdi32 -lwinmm -ldxguid  -mwindows
obj\Debug\main.o: In function `Z9LoadImageSs':
C:/Users/Ceset/Desktop/test/main.cpp:16: undefined reference to `IMG_Load'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
Last edited on
damn. this is so problematic. i tried 1.2.10(as adviced here http://www.cplusplus.com/forum/general/106595/ ) and it gave me prob too. so u know what i give up. i return to the sdl_loadbmp func back.
Last edited on
1st off, I wouldn't advise using an outdated version of sdl. 2.0 offers many enhancements over its predecessors, and increases efficiency tremendously if you know how to use it.

That said, it looks like you may have incorrectly installed SDL_Image. Double check that you added the appropriate files and folders to the linker. What I like to do is throw everything in with the SDL package (libs with sdl libs, includes, with sdl includes), then point to the DLL's manually as needed.
yeah i m not against 2.0 but sdl_image 1.2.12 is still working and i m sure it is fine. i know i have installed it incorrectly. but dont know how to install it correctly. i give u an image in the link(no download). in addition i tried to install SDL_ttf and it didnt worked too so i m the problem here. i reinstalled it over and over again. checked many tutorials about how to install but nothing happens. i m missing something. could someone tell me what did i do wrong looking at the image i uploaded.
Last edited on
closed account (N36fSL3A)
Did you properly set up SDL_Image?

Are you adding the "-lSDL_image" flag?

http://lazyfoo.net/SDL_tutorials/lesson03/index.php
1
2
-lmingw32 -lSDLmain -lSDL -lSDL2main -lSDL_image
-lSDL2_image -lSDL2_ttf

is in my compilers other linking options

if you take a look at the image i uploaded in my first post pls
giving the link again
http://postimg.org/image/uwaewwj75/

EDIT:
pls look at the image. i know u people can understand what is the problem
Last edited on
GCC's linker has been known to be sensitive regarding the order in which static libraries are passed to it. Try reordering your -l flags by passing the more basic libraries last. E.g. SDL2_image depends on SDL2, so pass SDL2 after SDL2_image.

Also, link either SDL libraries or SDL2 libraries. Not both, as it might cause conflicts.
i tried lots of combination including this one
1
2
-lmingw32 -lSDL -lSDLmain -lSDL_image
-lSDL2main -lSDL2_image -lSDL2_ttf


but nope sir.
edit: and also tried it without sdl2 libraries still no effect.
Last edited on
well i get the idea this could be because of the version conflict(sdl ver 1.2.15 sdl_image ver 1.2.12). so i changed sdl to 1.2.12. still no affect.

edit: well i tried sdl2 and sdl2_image libs. no matter what i changed the code into it gives me same problem undefined reference to (function). so sdl2_image lib also didnt installed properly
Last edited on
You could try installing it on a different compiler to see if the problem is your method of installation or compiler.

Also, have you double checked that you're using the mingw version of SDL_Image? IIRC there are different libs and includes for different compilers.
change
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
to
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

and change
-lmingw32 -lSDL -lSDLmain -lSDL_image
-lSDL2main -lSDL2_image -lSDL2_ttf

to
-lmingw32 -lSDL2main -lSDL2
-lSDL2_image -lSDL2_ttf

perhaps you don't have SDL_image version for SDL 1.2.12. You downloaded SDL2_image.
@roger911 i tried it with DevC++ before and it didnt worked also. give the same problem

mingw version of sdl_image is only possible at 2.0 not with 1.2 versions as far as know

@tntxtnt well i installed that more than once (4 or 5 times) and i m sure it is 1.2.12 (note even if i did that sdl2_image also contains IMG_Load func so it should give me a runtime prob if i were to or something like that). still i tried and no effect.
could someone give me exact links to install maybe i m installing somewhat wrong versions.

win 7 64 bit OS - codeblocks-12.11mingw-setup.exe

and a note from code blocks
NOTE: The codeblocks-12.11mingw-setup.exe file includes the GCC compiler and GDB debugger from TDM-GCC (version 4.7.1, 32 bit).
hahahahahaha. now i m done being patient. i have gone mad. i reinstalled code::blocks and libraries again and and it still says undefined reference to IMG_Load. and this time i just installed sdl2_image and it still says und... hahahahahahaha

EDIT: could someone tell me if compiler completes your code it means it sees the library right so i have linked .h file very well but what about .dlls and .a and .libs or there is something more ???

how funny its name is code::blocks and it blocks u from working on third party libraries haha(hey i wasnt serious about this)
Last edited on
http://www.threelas.com/2011/07/how-to-install-sdlimage-in-codeblocks.html

i swear i didnt passed even one step of this tutorial video. and it stilllllllll doesnt work.
removed content :D :D
Last edited on
Topic archived. No new replies allowed.