Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Failing at SDL

Name: Anonymous 2011-05-27 20:14

>Decide to go do the SDL tutorial on LazyFoo's site
>Type out first tutorial, code looks like so:

#include <SDL/SDL.h>

int main() {

        SDL_Surface* hello = NULL;
        SDL_Surface* screen = NULL;

        SDL_Init( SDL_INIT_EVERYTHING );
        screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
        hello = SDL_LoadBMP( "hello.bmp" );

        SDL_BlitSurface( hello, NULL, screen, NULL );
        SDL_Flip( screen );
        SDL_Delay( 2000 );

        return 0;
}


Compile like so

g++ -framework SDL -o SDLtest test.cc

Get the following linker error:

Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
     (maybe you meant: SDL_main())
ld: symbol(s) not found
collect2: ld returned 1 exit status

ld doesn't know what the fuck main is?

Name: Anonymous 2011-05-27 20:20

Hurr fucking durr.
Firstly, it's pretty basic knowledge that SDL replaces main with a macro (for SDL_main, coincidentally).
Secondly, why don't you declare main(int,char*) properly? It's been like that since the dawn of time, and changing it to main (void) for a library that should damn well expect it to have to arguments is the perfect evidence that you have absolutely no clue as to the inner workings of the technology  that you're working with (which you should, and if you think you don't have to, then I direct you in the direction of Java, Python or .NET).

Name: Anonymous 2011-05-27 20:46

g++ -lSDL -o SDLtest test.c
works for me

Name: Anonymous 2011-05-27 21:19

>>2

Erm... mind you I'm doing a tutorial on SDL, so you should expect me not to know anything about SDL...

But I tend to default main to no arguments unless I explicitly must have arguments.

Name: Anonymous 2011-05-27 23:57

>>4
Disregard the autistic people on this board, see http://en.wikipedia.org/wiki/Autism, in short they're unable to understand what it's like for a person who doesn't know any SDL after they have learned it, it's nothing personal, they're actually unable to put themselves in other peoples shoes.

First of all have you installed the SDL development files? >>3 should work for anyone who have them installed.

Name: Anonymous 2011-05-28 3:47

>>5
fuck you neurotypical faggot

Name: Anonymous 2011-05-28 7:08

>>4
The tutorial should start off by giving you some background on what you're working with. Most decent ones for most things do.

Name: Anonymous 2011-05-28 11:12

you missed (int argc, char *argv[]) and SDL_Quit(), you need to link with both SDL and SDLmain

Name: Anonymous 2011-05-28 12:39

>>2
Chill the fuck out.

Name: Anonymous 2011-05-28 18:11

The Jews are after me

Name: Anonymous 2011-05-28 18:55

SDL 1.2 is shit.

SDL 1.3 HG HEAD is superior.

Don't change these.
Name: Email:
Entire Thread Thread List