SDL_image not SDL

Jul 20, 2013 at 8:47pm
closed account (NUj6URfi)
I found some different code that had less errors. Now the only error I am getting is

[Linker error] undefined reference to `IMG_Load'

My code is:
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>

int main(int argc, char **argv)
{
		  int exited=0;
		  SDL_Surface *screen, *image;
		  SDL_Rect rect;

		  if(SDL_Init(SDL_INIT_VIDEO)<0){
					 fprintf(stderr,"Problem loading movie.",
SDL_GetError());
					 exit(1);
		  }
		  atexit(SDL_Quit);
		  screen=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE);
		  if(screen==NULL){
					 fprintf(stderr,"Couldn't set video mode: %s\n",
SDL_GetError());
					 exit(1);
		  }
		  image=IMG_Load("Frame1.jpg");
		  if(image==NULL){
					 fprintf(stderr,"Couldn't load movie\n");
					 exit(1);
		  }
		
if(SDL_SetColorKey(image,SDL_RLEACCEL,SDL_MapRGB(image->format,0,0,0))){
					 fprintf(stderr,"Couldn't ser color key: %s\n",SDL_GetError());
					 exit(1);
		  }
		  image=SDL_DisplayFormat(image);
		  rect.x=100;rect.y=100;rect.w=image->w;rect.h=image->h;
		  SDL_BlitSurface(image,0,screen,&rect);
		  SDL_UpdateRects(screen,1,&rect);
		  while(exited==0){
					SDL_Event event;
					if(SDL_PollEvent(&event)==1){
							  if((event.type==SDL_KEYDOWN &&
event.key.keysym.sym==SDLK_ESCAPE) ||
(event.type==SDL_QUIT))exited=1;
					}
		  }
		  return 0;
}


What can I do to fix this? I tried googling it.
Jul 20, 2013 at 8:58pm
closed account (NUj6URfi)
I added into my linker

-lmingw32 -lSDL_image -ISDL -mwindows
and know it says missing SDL_Image.dll. I put it in with the cpp. That didn't work. Where should I put it?
Jul 20, 2013 at 9:00pm
closed account (NUj6URfi)
So I put my dll in a libraries folder. Now I click compile and run and nothing appears when I click run. What is up with that? I don't even see a flicker.
Jul 20, 2013 at 9:03pm
closed account (NUj6URfi)
Now after working, it says file format not recognized. Nothing else. What does that mean?
Jul 21, 2013 at 12:09am
closed account (NUj6URfi)
Bump.
Jul 21, 2013 at 12:21am
closed account (NUj6URfi)
Bump.
Jul 21, 2013 at 12:27am
copy zlib1.dll, libpng15-15.dll, libjpeg-8.dll, libtiff-5.dll, libwebp-2.dll along with the licenses (in your original SDL_image.dll folder) to your libraries folder.
Last edited on Jul 21, 2013 at 12:27am
Jul 21, 2013 at 12:42am
closed account (NUj6URfi)
Still have an error.
Jul 21, 2013 at 4:41am
Put the SDL .dll files in the same folder as the executable binary. The lib .dll files and include .h files get added to project settings. Also put any resources such as images in the same folder as the binary executable.

-lmingw32 -lSDL_image -ISDL -mwindows

Try:
-lmingw32 -lSDLmain -lSDL -lSDL_image -mwindows

I am not sure if you need the -mwindows and the capital I in front of SDL should be a lowercase L
Last edited on Jul 21, 2013 at 4:44am
Jul 21, 2013 at 12:37pm
closed account (NUj6URfi)
Same error.
Jul 21, 2013 at 1:09pm
closed account (NUj6URfi)
Now I have gotten rid of the errors but when I click compile it says done, but then I click run and it says file not compiled, while my log says

Compiler: Default compiler
Building Makefile:
Executing make...
make.exe -f all
g++.exe ../Test.o -o "Game.exe" -L"C:/ProgramFiles/Dev-Cpp/lib" -L -L -L -mwindows -lmingw32 -lSDLmain -lSDL -lmingw32 -lSDLmain -lSDL -lSDL_image -mwindows

Execution terminated
Compilation successful
Jul 21, 2013 at 1:47pm
closed account (NUj6URfi)
Bump.
Jul 21, 2013 at 3:11pm
Do you have the correct version of the SDL.dll and SDL_image.dll in the same folder as the executable? Also I notice that there is no -L "SDL lib directory" Did you put the SDL lib files in the Dev-cpp lib directory?
What kind of anitvirus are you running? Does it block executables without telling you?

EDIT: Seriously quit over bumping your posts. Bumps should only be used when it has been a few days. It takes away from other users who are also asking for help.
Last edited on Jul 21, 2013 at 3:17pm
Jul 22, 2013 at 1:07pm
closed account (NUj6URfi)
I have an low-level antivirus which allows me to do this stuff and sdl does have a lib. The dlls are in the a dll folder I included as a lib folder. I put them with the cpp but I got an error dll not found and the lib folder include (even though they are dlls)fixed it.
Jul 22, 2013 at 3:46pm
You need to put the executable dll files in the same directory as the exe file for your program.
http://lazyfoo.net/SDL_tutorials/lesson01/windows/devcpp/index.php
Just read step 5 to see what I am talking about.
These are additional dll files that do NOT go in the dev-c++ lib directory.
Jul 22, 2013 at 4:33pm
closed account (NUj6URfi)
It was but my compiler couldn't find the dll so I moved It to a lib folder on my desktop than I included the lib folder as a lib folder.
Jul 22, 2013 at 4:43pm
closed account (NUj6URfi)
Got it to work. Thanks for all your help.
Last edited on Jul 22, 2013 at 4:47pm
Topic archived. No new replies allowed.