Q: Win32 link error _WinMainCRTStartup

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave–

David MacCormack
@David_MacCormack

This is because you should have set up your project as “Win32 Console
Application” not as “Win32 Application”.

Vlad> ----- Original Message -----

From: David MacCormack [mailto:djm@maccormack.net]
Sent: Thursday, 19 April, 2001 11:07 AM
To: sdl at mail.lokigames.com
Subject: [SDL] Q: Win32 link error _WinMainCRTStartup…

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave


David MacCormack
djm at maccormack.net

How did you create your project ?
Make sure it is a Win32 application.

Personnaly, I create a C++ source without project
and try to compile it, letting VC create a default project.
Then, I modify this project to add libs etc…

The advantage in this method, is that your program
will open 2 windows:

  • Your SDL window with all your graphic stuff
  • A console window with stdin,stdout,stderr…
    Very convenient for debugging…>

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave


David MacCormack
djm at maccormack.net

try this:
#ifdef WIN32
#include <windows.h>
#endif

Now I myself still can’t compile under VC++ 6 with openGL, but I can compile
the nehe sdl opengl lessons with the downloaded vc workspace. If i try to
make my own workspace for the same code, I cant compile, it gives errors
concerning opengl functions e.g
asd.obj : error LNK2001: unresolved external symbol _gluPerspective at 32
So I just use one of the nehe workspaces and add files to make my own
project.

The problem is now I get compiler errors if I put class declerations in
header files
The syntax is correct, because the same files worked in another app. The
problem is with the application/setup, not the class.

In the bsp.h file:
class bsp {
public:
bspdata_t bspdata;
bsp(char* fileName);
~bsp();
};

And when I compile:
e:\ngendev\bsp.h(356) : error C2061: syntax error : identifier 'bsp’
e:\ngendev\bsp.h(356) : error C2059: syntax error : ';'
e:\ngendev\bsp.h(356) : error C2449: found ‘{’ at file scope (missing
function header?)
e:\ngendev\bsp.h(407) : error C2059: syntax error : '}'
bsprender.cpp
Error executing cl.exe.

lesson10.exe - 4 error(s), 0 warning(s)

Does anyone know whats happening?> ----- Original Message -----

From: David MacCormack [mailto:djm@maccormack.net]
Sent: Thursday, April 19, 2001 1:07 PM
To: sdl at mail.lokigames.com
Subject: [SDL] Q: Win32 link error _WinMainCRTStartup…

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave


David MacCormack
djm at maccormack.net

Wrong- none of my sdl apps has been anything else then "Win32 application"
and all works fine.

Kovacs> This is because you should have set up your project as "Win32 Console

Application" not as “Win32 Application”.

asd.obj : error LNK2001: unresolved external symbol _gluPerspective at 32
So I just use one of the nehe workspaces and add files to make my own

Just link with glu.lib or whatever… :wink:

The problem is now I get compiler errors if I put class declerations in
header files
The syntax is correct, because the same files worked in another app. The
problem is with the application/setup, not the class.

In the bsp.h file:
class bsp {
public:
bspdata_t bspdata;
bsp(char* fileName);
~bsp();
};

Check whether all with your include files is ok. You should try to include
it (for testing) only in bsp.cpp and then see what happens.
Maybe there is already class bsp declared or something like this. Maybe you
should try to change name.

Kovacs

The liniking errors are because you have to put into the
Project->Settings->Link
opengl32.lib glu32.lib
before all the other libraries listed there.

Vlad.> ----- Original Message -----

From: Konrad von Backstr?m [mailto:konrad.vbackstrom@datavoice.co.za]
Sent: Thursday, 19 April, 2001 1:21 PM
To: 'sdl at lokigames.com
Subject: RE: [SDL] Q: Win32 link error _WinMainCRTStartup…

try this:
#ifdef WIN32
#include <windows.h>
#endif

Now I myself still can’t compile under VC++ 6 with openGL, but I can compile
the nehe sdl opengl lessons with the downloaded vc workspace. If i try to
make my own workspace for the same code, I cant compile, it gives errors
concerning opengl functions e.g
asd.obj : error LNK2001: unresolved external symbol _gluPerspective at 32
So I just use one of the nehe workspaces and add files to make my own
project.

The problem is now I get compiler errors if I put class declerations in
header files
The syntax is correct, because the same files worked in another app. The
problem is with the application/setup, not the class.

In the bsp.h file:
class bsp {
public:
bspdata_t bspdata;
bsp(char* fileName);
~bsp();
};

And when I compile:
e:\ngendev\bsp.h(356) : error C2061: syntax error : identifier 'bsp’
e:\ngendev\bsp.h(356) : error C2059: syntax error : ';'
e:\ngendev\bsp.h(356) : error C2449: found ‘{’ at file scope (missing
function header?)
e:\ngendev\bsp.h(407) : error C2059: syntax error : '}'
bsprender.cpp
Error executing cl.exe.

lesson10.exe - 4 error(s), 0 warning(s)

Does anyone know whats happening?

-----Original Message-----
From: David MacCormack [mailto:djm@maccormack.net]
Sent: Thursday, April 19, 2001 1:07 PM
To: sdl at mail.lokigames.com
Subject: [SDL] Q: Win32 link error _WinMainCRTStartup…

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave


David MacCormack
djm at maccormack.net

I think both works.

With a project setup as Win32 application you have only the SDL window.
With a project setup as Win32 Console Application you have both your
main SDL window AND the console window.> ----- Original Message -----

From: kovacs@mt.lv (Janis Kovalevskis)
To:
Sent: Thursday, April 19, 2001 3:44 PM
Subject: Re: [SDL] Q: Win32 link error _WinMainCRTStartup…

Wrong- none of my sdl apps has been anything else then "Win32 application"
and all works fine.

Kovacs

This is because you should have set up your project as “Win32 Console
Application” not as “Win32 Application”.

And when I compile:
e:\ngendev\bsp.h(356) : error C2061: syntax error : identifier ‘bsp’

All nehe tutorials are C programs, not C++. MSVC++ will enforce C
rules (no classes, declarations of variables before any function
calls, etc…) if you compile a .c file. (and BTW in Windows, .C
(capital ‘c’) is the same as .c and doesn’t mean C++)–

Olivier A. Dagenais - Software Architect and Developer

Then in those applications, you have defined WinMain() somewhere. A console
application uses the traditional C main() function, but when it comes to
Win32 applications, Microsoft decided to be clever or whatever, and used
WinMain() instead of main(). Part of their need to always be different I
guess. In any case, if you make a Win32 application, you have to have a
WinMain() function or else you will get link errors about it being missing,
and that is EXACTLY the error message you are getting.

Try this if you don’t believe me. Make a new Win32 project, and then search
all these default files it created for you for WinMain(). Then try removing
that function and compiling. You should get the same error message.On Thursday 19 April 2001 06:44, you wrote:

Wrong- none of my sdl apps has been anything else then "Win32 application"
and all works fine.

Kovacs

This is because you should have set up your project as “Win32 Console
Application” not as “Win32 Application”.

Actually, after a little more playing around, I figured it out. Becuase I
had /NODEFAULT specified (I had to, otherwise I get errors about
redefinition of externals) I had to explicitly include msvcrt.lib. When
I added that, everything worked just peachy. Thanks to everyone who
responded; I didn’t realize that I get so many responses so fast :). Good
to see that there’s such a dedicated user base.

DaveOn Thu, 19 Apr 2001, David MacCormack wrote:

Hi there. I’m trying to compile the simple example app under
Visual C++ 6.

#include "SDL.h"
int main(int argc, char** argv) {
return 0;
}

I’ve followed all of the steps in VisualC.html, added the
include/lib paths, added sdl.lib and sdlmain.lib to the list of libs, set
to compile as Multithreaded DLL, etc… though I get the following error
upon build:

unresolved external symbox _WinMainCRTStartup.

Anyone seen this one before?

Dave

David MacCormack
@David_MacCormack

Close, but not quite :). If I didn’t declare a WinMain then I would get
a link error to the effect of “Missing WinMain at 16”. As it turns out,
SDL declares a WinMain (and you link to it via SDLmain.lib I think)
so the programmer – even if you’ve created a Win32 Application –
should make a main(…) function. Which SDL will call. I believe
this was done so that SDL apps are the same across platforms. I’m still
new to SDL mind you, so I could be wrong about that. But that’s my
impression.

DaveOn Thu, 19 Apr 2001, Jason Hoffoss wrote:

Then in those applications, you have defined WinMain() somewhere. A console
application uses the traditional C main() function, but when it comes to
Win32 applications, Microsoft decided to be clever or whatever, and used
WinMain() instead of main(). Part of their need to always be different I
guess. In any case, if you make a Win32 application, you have to have a
WinMain() function or else you will get link errors about it being missing,
and that is EXACTLY the error message you are getting.

Try this if you don’t believe me. Make a new Win32 project, and then search
all these default files it created for you for WinMain(). Then try removing
that function and compiling. You should get the same error message.

On Thursday 19 April 2001 06:44, you wrote:

Wrong- none of my sdl apps has been anything else then "Win32 application"
and all works fine.

Kovacs

This is because you should have set up your project as “Win32 Console
Application” not as “Win32 Application”.

David MacCormack
@David_MacCormack

“David MacCormack” wrote

As it turns out,
SDL declares a WinMain (and you link to it via SDLmain.lib I think)
so the programmer – even if you’ve created a Win32 Application –
should make a main(…) function. Which SDL will call. I believe
this was done so that SDL apps are the same across platforms.

bullseye.

actually, what’s going on (in case you care) is even more black
magical than you’d think. it is true that SDLmain.lib has its
own WinMain function, so you can stick with just main(). but,
inside the headers SDL does a “#define main SDL_main”. so what
really happens is your main() function is secretly being renamed
on windows platforms. this function is then called from the SDLmain
library once things are initialized.

Actually, after a little more playing around, I figured it out. Becuase I
had /NODEFAULT specified (I had to, otherwise I get errors about
redefinition of externals) I had to explicitly include msvcrt.lib. When

Are you sure u are using multithread dll?

Kovacs

blank workspace, and believe me- no other files than appropriate dsw, dsp
and ncb are created. :wink: So if you can show me where this winmain is hiding,
then just do it :wink:

Maybe you forgot to link SDLmain.lib …

– Timo Suoranta – @Timo_K_Suoranta --On Fri, 20 Apr 2001, Kovacs wrote:

Try this if you don’t believe me. Make a new Win32 project, and then
search
all these default files it created for you for WinMain(). Then try
removing
that function and compiling. You should get the same error message.

I don’t believe you… :wink: I have reason for this, because things you are
telling are plain wrong.
I usually, when i start new project/workspace use new->Win32 Application,
blank workspace, and believe me- no other files than appropriate dsw, dsp
and ncb are created. :wink: So if you can show me where this winmain is hiding,
then just do it :wink:

Kovacs