I’m trying to build sdl library on VC++ and VS.net.
But on both IDE’s I get link error message which says
“unresolved external SDL_main”. I’m not making the
mistake you have mentioned in the windows faq and have
build vc and vc7 sdl projects successfully but the
problem remains. Please, tell me what’s going wrong?=====
There are two things that can cause this error AFAIK.
a) You havn’t linked to "SDLmain"
b) You do not have a main() function
Sameer Rafiq wrote:>I’m trying to build sdl library on VC++ and VS.net.
But on both IDE’s I get link error message which says
"unresolved external SDL_main". I’m not making the
mistake you have mentioned in the windows faq and have
build vc and vc7 sdl projects successfully but the
problem remains. Please, tell me what’s going wrong?
just to add a third, ive encountered this problem when…
c) The main function is declared incorrectly, ie it isnt…
int main(int argc,char **argv)> ----- Original Message -----
From: grembo@swiftdsl.com.au (grembo)
To: "A list for developers using the SDL library. (includes SDL-announce)"
Sent: Friday, August 20, 2004 4:47 PM
Subject: Re: [SDL] unresolved external reference error persists in win32
There are two things that can cause this error AFAIK.
a) You havn’t linked to "SDLmain"
b) You do not have a main() function
Sameer Rafiq wrote:
I’m trying to build sdl library on VC++ and VS.net.
But on both IDE’s I get link error message which says
"unresolved external SDL_main". I’m not making the
mistake you have mentioned in the windows faq and have
build vc and vc7 sdl projects successfully but the
problem remains. Please, tell me what’s going wrong?
I extract the visualc.zip file into source folder (
Open the workspace file and build both projects
without any errors.
Create an empty win32 application project and a new
.cpp file and copy paste “sdl initialization code” (
from sdl documentaion )
Set the project settings runtime to Multithreaded
DLL.
Tool->Options->Directories tab->include
E:\GAME\SDL\WIN32\SDL-1.2.7\INCLUDE and lib
E:\GAME\SDL\WIN32\SDL-1.2.7\LIB
Now there is a confusion in win32 faq which is as
follows " The “include directory” I am referring to is
the include folder within the main SDL directory (the
one that this HTML file located within)." This html
file is in win32 develop folder and source folder. I
have tried both approaches first include the file from
win32 and then from source folder but none worked.
Copy the SDL.dll file in my project folder and add
SDL.lib and SDLmain.lib to my project.
After compiling the first error is about exit()
function which is
"e:\game\sdl\examples\ex1\ex1.cpp(11) : error C2065:
‘exit’ : undeclared identifier"
After commenting out exit() and using return 0 this
error occurs "SDLmain.lib(SDL_win32_main.obj) : error
LNK2001: unresolved external symbol _SDL_main"
Please tell me what’s missing . The code is as
follows:
#include “SDL.h” /* All SDL App’s need this */ #include <stdio.h>
int main() {
printf("Initializing SDL.\n");
/* Initialize defaults, Video and Audio */
if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1))
{
printf(“Could not initialize SDL: %s.\n”,
SDL_GetError());
exit(-1);
}
I extract the visualc.zip file into source folder (
Open the workspace file and build both projects
without any errors.
Create an empty win32 application project and a new
.cpp file and copy paste “sdl initialization code” (
from sdl documentaion )
Set the project settings runtime to Multithreaded
DLL.
Tool->Options->Directories tab->include
E:\GAME\SDL\WIN32\SDL-1.2.7\INCLUDE and lib
E:\GAME\SDL\WIN32\SDL-1.2.7\LIB
Now there is a confusion in win32 faq which is as
follows " The “include directory” I am referring to is
the include folder within the main SDL directory (the
one that this HTML file located within)." This html
file is in win32 develop folder and source folder. I
have tried both approaches first include the file from
win32 and then from source folder but none worked.
Copy the SDL.dll file in my project folder and add
SDL.lib and SDLmain.lib to my project.
After compiling the first error is about exit()
function which is
"e:\game\sdl\examples\ex1\ex1.cpp(11) : error C2065:
‘exit’ : undeclared identifier"
After commenting out exit() and using return 0 this
error occurs "SDLmain.lib(SDL_win32_main.obj) : error
LNK2001: unresolved external symbol _SDL_main"
Please tell me what’s missing . The code is as
follows:
#include “SDL.h” /* All SDL App’s need this */ #include <stdio.h>