_WinMainCRTStartup problem with Visual Studio .NET 2003

Hello happy SDL coders :slight_smile:

sorry to annoy you with what will probably appear to be a beginner’s problem,
but after having googled during hours, you are my last hope before I either
turn crazy or erase my harddisk (or both).

I’m trying to use SDL with Visual Studio .NET 2003, and I keep having the
linker complaining. Here is a typical message I get :

“essaisdl3 error LNK2019: symbole externe non r?solu _WinMain at 16 r?f?renc?
dans la fonction _WinMainCRTStartup”
(unresolved external symbol _WinMain at 16 referenced in the function
__WinMainCRTStartup)

I tried everything that was written in the VisualC.html file. I tried many
things I found when googling… And I keep having this kind of messages.

Here’s the typical code I try to compile :

#include “stdafx.h”
#include “SDL.h”

int main( int argc, char* argv[] )
{
return 0;
}

I can’t get rid off #include “stdafx.h”, or VisualStudio complains and says :
“fatal error C1010: fin de fichier inattendue lors de la recherche d’une
directive d’en-t?te pr?compil?”
(unsuspected end of file when searching for an inclusion directive)

I downloaded the sources of PearPC, as it’s an SDL project, and had a look at
how it handles main() :

====PearPC====
#ifdef main
// Get rid of stupid SDL main redefinitions
#undef main
extern “C” int SDL_main(int argc, char *argv[])
{
return 0;
}
#endif

int main(int argc, char *argv[])
{
//code
}============

I added that to my code, but it changes nothing.

I’m despaired.

Do you know what’s going so wrong with my tryings?

Help would be much appreciated :slight_smile:

Thanks,

/Julien

PS: here are things I tried :

  • various VS project creations : 16 bits console, 32 bits console, Win32
    application, …
  • using multithreaded debug/release DLLs
  • various names for main() : _main() , _tmain(), _WinMain(), …
  • adding the .lib files directly in the project, or copying them in VS’s libs
    directory (same thing with header files)
  • with and without #include “stdafx.h”
  • various main() signatures

… and combinations of all that

Close, it’s unexpected end of file when searching for a precompiled header
directive. Turn off precompiled headers, it’s somewhere under the C++
project options. and get rid of stdafx.h. That might help.On Tuesday 26 April 2005 20:06, Julien Marcel wrote:

I’m trying to use SDL with Visual Studio .NET 2003, and I keep having the
linker complaining. Here is a typical message I get :

“essaisdl3 error LNK2019: symbole externe non r?solu _WinMain at 16 r?f?renc?
dans la fonction _WinMainCRTStartup”
(unresolved external symbol _WinMain at 16 referenced in the function
__WinMainCRTStartup)

I tried everything that was written in the VisualC.html file. I tried many
things I found when googling… And I keep having this kind of messages.

Here’s the typical code I try to compile :

#include “stdafx.h”
#include “SDL.h”

int main( int argc, char* argv[] )
{
return 0;
}

I can’t get rid off #include “stdafx.h”, or VisualStudio complains and says
: “fatal error C1010: fin de fichier inattendue lors de la recherche d’une
directive d’en-t?te pr?compil?”
(unsuspected end of file when searching for an inclusion directive)

And don’t forget to also link against the SDLmain library.

Tyler Montbriand wrote:>On Tuesday 26 April 2005 20:06, Julien Marcel wrote:

I’m trying to use SDL with Visual Studio .NET 2003, and I keep having the
linker complaining. Here is a typical message I get :

“essaisdl3 error LNK2019: symbole externe non r??solu _WinMain at 16 r??f??renc??
dans la fonction _WinMainCRTStartup”
(unresolved external symbol _WinMain at 16 referenced in the function
__WinMainCRTStartup)

I tried everything that was written in the VisualC.html file. I tried many
things I found when googling… And I keep having this kind of messages.

Here’s the typical code I try to compile :

#include “stdafx.h”
#include “SDL.h”

int main( int argc, char* argv[] )
{
return 0;
}

I can’t get rid off #include “stdafx.h”, or VisualStudio complains and says
: “fatal error C1010: fin de fichier inattendue lors de la recherche d’une
directive d’en-t??te pr??compil??”
(unsuspected end of file when searching for an inclusion directive)

Close, it’s unexpected end of file when searching for a precompiled header
directive. Turn off precompiled headers, it’s somewhere under the C++
project options. and get rid of stdafx.h. That might help.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

–
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 25-Apr-05

Thanks a lot to the both of you!

I now have no longer problems with “stdafx.h”, and my project compile now with
no errors :slight_smile:

Thanks again!

/Julien

In your linker flags define your entry point as SDL_main.
For .NET it’s done like this:

/ENTRY:SDL_main

hope that helps,
Kos.> ----- Original Message -----

From: sdl-bounces+kos=climaxgroup.com@libsdl.org
[mailto:sdl-bounces+kos=climaxgroup.com at libsdl.org]On Behalf Of Julien
Marcel
Sent: 27 April 2005 03:06
To: sdl at libsdl.org
Subject: [SDL] _WinMainCRTStartup problem with Visual Studio .NET 2003

Hello happy SDL coders :slight_smile:

sorry to annoy you with what will probably appear to be a beginner’s
problem,
but after having googled during hours, you are my last hope before I either
turn crazy or erase my harddisk (or both).

I’m trying to use SDL with Visual Studio .NET 2003, and I keep having the
linker complaining. Here is a typical message I get :

“essaisdl3 error LNK2019: symbole externe non r?solu _WinMain at 16 r?f?renc?
dans la fonction _WinMainCRTStartup”
(unresolved external symbol _WinMain at 16 referenced in the function
__WinMainCRTStartup)

I tried everything that was written in the VisualC.html file. I tried many
things I found when googling… And I keep having this kind of messages.

Here’s the typical code I try to compile :

#include “stdafx.h”
#include “SDL.h”

int main( int argc, char* argv[] )
{
return 0;
}

I can’t get rid off #include “stdafx.h”, or VisualStudio complains and says
:
“fatal error C1010: fin de fichier inattendue lors de la recherche d’une
directive d’en-t?te pr?compil?”
(unsuspected end of file when searching for an inclusion directive)

I downloaded the sources of PearPC, as it’s an SDL project, and had a look
at
how it handles main() :

====PearPC====
#ifdef main
// Get rid of stupid SDL main redefinitions
#undef main
extern “C” int SDL_main(int argc, char *argv[])
{
return 0;
}
#endif

int main(int argc, char *argv[])
{
//code
}

I added that to my code, but it changes nothing.

I’m despaired.

Do you know what’s going so wrong with my tryings?

Help would be much appreciated :slight_smile:

Thanks,

/Julien

PS: here are things I tried :

  • various VS project creations : 16 bits console, 32 bits console, Win32
    application, …
  • using multithreaded debug/release DLLs
  • various names for main() : _main() , _tmain(), _WinMain(), …
  • adding the .lib files directly in the project, or copying them in VS’s
    libs
    directory (same thing with header files)
  • with and without #include “stdafx.h”
  • various main() signatures

… and combinations of all that


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,
I am using “export SDL_AUDIODRIVER=esd” in the shell prior to running my program
and it resolves some audio issue for me (I’m not quite sure why or how it works,
but it works). The thing is, it gets really annoying for me to type this in
every time before running the program, especially since I’m running multiple
clients, each of for which I need to do it.

I tried doing “system(“export SDL_AUDIODRIVER=esd”);” and I thought that would
effectively fix the issue, but it doesn’t. Seems I need to export before even
running the program at all. Does anyone know a good way to add some lines of
code to my program so that I don’t have to pre-type it in everytime?

Thanks!
Shu

‘system’ creates a whole new process, with it’s own independent memory and
environment space, then runs “export SDL_AUDIODRIVER=esd” in a shell in that
new process. This new process recieves a full copy of the current
environment variables, but any changes inside it don’t get sent back.
Definitely not what you want.

Try “putenv(“SDL_AUDIODRIVER=esd”);” instead. It needs stdlib.h.On Wednesday 27 April 2005 07:33, shu wrote:

I tried doing “system(“export SDL_AUDIODRIVER=esd”);” and I thought that
would effectively fix the issue, but it doesn’t.

Quoting Tyler Montbriand :> On Wednesday 27 April 2005 07:33, shu wrote:

I tried doing “system(“export SDL_AUDIODRIVER=esd”);” and I thought that
would effectively fix the issue, but it doesn’t.
‘system’ creates a whole new process, with it’s own independent memory and
environment space, then runs “export SDL_AUDIODRIVER=esd” in a shell in that
new process. This new process recieves a full copy of the current
environment variables, but any changes inside it don’t get sent back.
Definitely not what you want.

Try “putenv(“SDL_AUDIODRIVER=esd”);” instead. It needs stdlib.h.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thank you, worked perfectly!

Shu