I cannot find any syntax problems with this file, but it does not compile.
I have the SDL libraries, and I have compiled other programs that use SDL.
The errors are:
In function main':blitting-surfaces-sdl.c:(.text+0x19): undefined reference to
SDL_Init’
:blitting-surfaces-sdl.c:(.text+0x22): undefined reference to SDL_GetError' :blitting-surfaces-sdl.c:(.text+0x45): undefined reference to
SDL_Quit’
:blitting-surfaces-sdl.c:(.text+0x6e): undefined reference to SDL_SetVideoMode':blitting-surfaces-sdl.c:(.text+0x7c): undefined reference to
SDL_GetError’
:blitting-surfaces-sdl.c:(.text+0xac): undefined reference to SDL_RWFromFile' :blitting-surfaces-sdl.c:(.text+0xbc): undefined reference to
SDL_LoadBMP_RW’
:blitting-surfaces-sdl.c:(.text+0x149): undefined reference to SDL_UpperBlit' :blitting-surfaces-sdl.c:(.text+0x174): undefined reference to
SDL_UpdateRect’
:blitting-surfaces-sdl.c:(.text+0x180): undefined reference to SDL_Delay' :blitting-surfaces-sdl.c:(.text+0x18b): undefined reference to
SDL_FreeSurface’collect2: ld returned 1 exit status
Also, I have replaced the headers with both
#include </usr/include/SDL/SDL.h>
#include </usr/include/SDL/SDL_image.h>
#include </usr/include/SDL/SDL_video.h>
and
#include <stdlib.h>
#if defined(_MSC_VER)
#include “SDL.h”
#else
#include “SDL/SDL.h”
#endif
if the path is wrong, GCC reports that SDL.h is not found; but if it is correct, it does not list any problem finding headers, but still cannot ‘use’ them.
The program is:
#include <stdio.h>
#include <stdlib.h>
int main()
{
SDL_Surface *screen;
SDL_Surface *image;
SDL_Rect src, dest;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(256,256,16,0);
if(screen == NULL) {
printf("Unable to set video mode: %s\n", SDL_GetError());
return 1;
}
image = SDL_LoadBMP(“pygame_icon.bmp”);
if(image == NULL) {
printf(“Unable to load bitmap.\n”);
return 1;
}
src.x = 0;
src.y = 0;
src.w = image -> w;
src.h = image -> h;
dest.x = 0;
dest.y = 0;
dest.w = image -> w;
dest.h = image -> h;
SDL_BlitSurface(image, &src, screen, &dest);
SDL_UpdateRect(screen, 0, 0, 0, 0);
SDL_Delay(3000);
SDL_FreeSurface(image);
return 0;
}---------------------------------
See the all-new, redesigned Yahoo.com. Check it out.