Visual C++

Hello again,

I tried to compile under Window$
i get the error ->
--------------------Configuration: test1 - Win32
Debug--------------------
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
But if I put #undef main in my code Visual build it !
So why SDL_main.h need #define main … in that case ?
thanks

–>pouf pouf

Franck Nouyriga schrieb:

Hello again,

I tried to compile under Window$
i get the error ->
--------------------Configuration: test1 - Win32
Debug--------------------
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals

I’m not sure, but could it be because you have written int main instead
of just main? The int is unnecessary with the SDL.–
Christian Biesinger
Get Paid To Surf:
http://www.AdOne.de/startup.php?werber=45130
Hi! I’m a signature virus! Copy me into your signature file to help me
spread!

Franck Nouyriga schrieb:

Hello again,

I tried to compile under Window$
i get the error ->
--------------------Configuration: test1 - Win32
Debug--------------------
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals

I’m not sure, but could it be because you have written int main instead
of just main? The int is unnecessary with the SDL.

That’s actually not true with the 1.0 version.
You need to include <SDL/SDL.h> in the file containing your main(),
and you need to link with SDLmain.lib

Take a look at VisualC.html in the final 1.0 archives.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Christian Biesinger wrote:

I’m not sure, but could it be because you have written int main instead
of just main? The int is unnecessary with the SDL.

Well, AFAIK, the int is necessary with Standard C, at least if you
want to be strict about prototypes. A lot of people write void main()
without realizing that it goes against the C standard if you actually
read the legalese. Just writing main() without the int is the same as
int main() AFAIK, because the default return type if unspecified is
int. Or does VC++ suddenly not obey the C standard (which has been
ratified and stable for at least seven years)?–

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman

“Rafael R. Sevilla” schrieb:

Christian Biesinger wrote:

I’m not sure, but could it be because you have written int main instead
of just main? The int is unnecessary with the SDL.

Well, AFAIK, the int is necessary with Standard C, at least if you
want to be strict about prototypes. A lot of people write void main()
without realizing that it goes against the C standard if you actually
read the legalese. Just writing main() without the int is the same as
int main() AFAIK, because the default return type if unspecified is
int. Or does VC++ suddenly not obey the C standard (which has been
ratified and stable for at least seven years)?

Of course, you SHOULD write the int od void or whatever main.
But at least with the 0.10 Version of the SDL you were not allowed to
write int main. It didn’t compile then!
Okay, I just found out that in 1.0 it works even with the int. But in
the older Versions this was not possible!!!–
Christian Biesinger
Get Paid To Surf:
http://www.AdOne.de/startup.php?werber=45130
Hi! I’m a signature virus! Copy me into your signature file to help me
spread!

Of course, you SHOULD write the int od void or whatever main.
But at least with the 0.10 Version of the SDL you were not allowed to
write int main. It didn’t compile then!
Okay, I just found out that in 1.0 it works even with the int. But in
the older Versions this was not possible!!!

That’s correct. I was working around some ugly name mangling issues
with C++.

The gist of the current (non-hacked) solution is that if you want to
have your C++ program work properly, you need to declare main() as
extern “C”.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Franck Nouyriga wrote:

Hello again,

I tried to compile under Window$
i get the error ->
--------------------Configuration: test1 - Win32
Debug--------------------
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
But if I put #undef main in my code Visual build it !
So why SDL_main.h need #define main … in that case ?
thanks

I just tried to build under Windows using VC++6 and SDL 1.0.1.

I found a similar problem, where LIBCD.lib had a warning about default
libraries, and SDL_main.lib had two errors: multiple definition of _main
(other in my main object file) and unresolved _SDL_main.

I followed the advice in the documentation. Investigation revealed that
SDL/SDLmain.h was in fact defining main to SDL_main. Yet the leading
underscores bothered me.

I changed my main to be SDL_main, and the program linked. (It crashes,
but that’s another post.)

So, where is the leading underscore coming from? Anyone else have that
trouble?–
Marc Lepage
Software Developer
Molecular Mining Corporation
http://www.molecularmining.com/

Hi,

i'm using VC++ 6.0 and SDL 1.0 and everything works. Just did what was

writen in VisualC.zip (or whatever), and everything rocks.

Kovacs> ----- Original Message -----

From: mlepage@molecularmining.com (Marc A. Lepage)
Newsgroups: loki.open-source.sdl
To:
Sent: otrdiena, 2000. gada 4. janvaris 4:28
Subject: [SDL] Re: Visual C++

Franck Nouyriga wrote:

Hello again,

I tried to compile under Window$
i get the error ->
--------------------Configuration: test1 - Win32
Debug--------------------
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
But if I put #undef main in my code Visual build it !
So why SDL_main.h need #define main … in that case ?
thanks

I just tried to build under Windows using VC++6 and SDL 1.0.1.

I found a similar problem, where LIBCD.lib had a warning about default
libraries, and SDL_main.lib had two errors: multiple definition of _main
(other in my main object file) and unresolved _SDL_main.

I followed the advice in the documentation. Investigation revealed that
SDL/SDLmain.h was in fact defining main to SDL_main. Yet the leading
underscores bothered me.

I changed my main to be SDL_main, and the program linked. (It crashes,
but that’s another post.)

So, where is the leading underscore coming from? Anyone else have that
trouble?


Marc Lepage
Software Developer
Molecular Mining Corporation
http://www.molecularmining.com/