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

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).

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