Skip to main content
gamedev.net
🔒 Locked

link error?

Started by Toadhead 2 replies 850+ views
Original Post
Toadhead
Toadhead
Why do I get a link error with this code:

#include <SDL/SDL.h>
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    
    
    if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
    { 
    cout << "Error" << endl;
    return 1;
    }

    atexit(SDL_Quit);


    SDL_Surface *screen;
    screen = SDL_SetVideoMode(800,600,0,SDL_HWSURFACE|SDL_DOUBLEBUF);





    return 0;
}

[link error] undifined refenrence to 'SDL_main' [build error] [SDLProject1.exe] Error 1 I linked the following files and normaly it works fine (with other codes) libmingw32.a libSDLmain.a libSDL.a so It's something in my code I guess but I don't know what :(
stormrunner
stormrunner
instead of
int main()

put
int main(int argc, char* argv[ ])

and it should work.
stormrunner
Toadhead
Toadhead
ow.. do you always need to add those arguments to the main function??

I thought you could just add them when you're going to use them in your program just like in the normal c++ :/


thanks for your help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.