Thread: SDL project won't compile (no code yet)

  1. #1
    Shadow12345
    Guest

    SDL project won't compile (no code yet)

    I am trying to build a SDL project. So far I haven't been able to properly set up the project, this is what happens:

    sdlmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol _SDL_main
    Debug/SDL.exe : fatal error LNK1120: 1 unresolved externals

    I get this before I even write any code in. I am pretty sure I have set up SDL correctly (I put the SDL.dll in system32 [I am currently on Windows 2000], I have selected multithreaded dll, and I added sdl.lib and sdlmain.lib libraries to the project)

    I do not know why this isn't working, and to tell you the truth I don't really even understand the errors I am getting (the ones listed above). If anyone can either shed some light specifically to what I am doing wrong in SDL, or if they can just give me some clarifications on what the errors mean, I will be very happy.
    Thank you thank you thank you.

  2. #2
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Assuming you've setup SDL correctly, make sure you're main looks like this:

    int main( int argc, char **argv )

    or

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

    you need to include the full command line arguments as parameters.
    If that doesn't take care of it let me know.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  3. #3
    Shadow12345
    Guest
    That seems to have taken care of it. Before I was just setting up the project settings and including header files, and then compiling with no main ( I was doing this just to make sure it could find all the header files and what not).

    Also what is the difference between

    int main( int argc, char **argv )

    and

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

    Your help is greatly appreciated

  4. #4
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Considering it looks like it is from VC++, instead of int main(blah...), type int main(void)...see if that works.

  5. #5
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    taylor is correct. SDL redefines main or something, and it only correctly redefines it if the command line arguments are there.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  6. #6
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Also what is the difference between
    (char**argv) is a pointer to a pointer of a location where chars are stored, and (char *argv[]) is a pointer to an array of chars. So basically, same difference.

    pointer* = undefined array[]
    "The mind, like a parachute, only functions when open."

  7. #7
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    By the way, what is SDL?
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  8. #8
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    This question was answered before in this exact thread, but it's a Library kinda like DirectX, but better, and also developed by a person who works(or worked) at Blizzard Entertainment..from what I've read.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code won't compile
    By monkles in forum C Programming
    Replies: 3
    Last Post: 05-28-2009, 01:45 PM
  2. want to start contributing c code to a project
    By stabu in forum C Programming
    Replies: 8
    Last Post: 12-18-2008, 09:15 PM
  3. Compile time of C versus C++ code
    By circuitbreaker in forum C++ Programming
    Replies: 20
    Last Post: 02-06-2008, 06:26 PM
  4. why the code can compile -- about function pointer
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2008, 03:25 AM
  5. Code will not compile - code from a book!
    By Chubz in forum C++ Programming
    Replies: 19
    Last Post: 09-12-2004, 10:21 PM