SDL in Visual C++

I have had SDL working with Visual C++ but I tried to use it for a GUI I
made. WHen I compile I get

SDL_main.obj : error LNK2001: unresolved external symbol _SDL_main

Any ideas.

Thanks,
Paul

This is a FAQ…

Check out http://www.libsdl.org/faq.php?action=listentries&category=4#48

Best regards,

-LorenOn Tue, 2002-08-27 at 10:55, Paul Newton wrote:

I have had SDL working with Visual C++ but I tried to use it for a GUI I
made. WHen I compile I get

SDL_main.obj : error LNK2001: unresolved external symbol _SDL_main

OK I had a look at that. I suspect that the problem is the fact that I
don’t have a main. What sholud I do. As I am developing a GUI I created my
project as a MFCAppWizard(Exe). How do I set this up so as it will allow me
to use SDL. I have followed all the steps in the “Using SDL with Microsoft
Visual C++ 5 and 6” by Lion Kimbro.

Thanks,
Paul> ----- Original Message -----

From: Loren Osborn [mailto:linux_dr@yahoo.com]
Sent: 27 August 2002 18:58
To: sdl at libsdl.org
Subject: Re: [SDL] SDL in Visual C++

On Tue, 2002-08-27 at 10:55, Paul Newton wrote:

I have had SDL working with Visual C++ but I tried to use it for a GUI I
made. WHen I compile I get

SDL_main.obj : error LNK2001: unresolved external symbol _SDL_main

This is a FAQ…

Check out http://www.libsdl.org/faq.php?action=listentries&category=4#48

Best regards,

-Loren


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

Hello Paul,

PN> OK I had a look at that. I suspect that the problem is the fact that I
PN> don’t have a main. What sholud I do. As I am developing a GUI I created my
PN> project as a MFCAppWizard(Exe). How do I set this up so as it will allow me
PN> to use SDL. I have followed all the steps in the “Using SDL with Microsoft
PN> Visual C++ 5 and 6” by Lion Kimbro.

You could create a main function that looks something like this:

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

I’ve never tried it as I tend to stay away from MFC as much as
possible, but that might be the solution you’re looking for! Just
remember to link with the SDL libraries…–
Best regards,
Neil mailto:n.griffiths at virgin.net

Where should I create this. What is the AfxMain. WHat else do I need to
do?

Thanks,
Paul> ----- Original Message -----

From: Neil Griffiths [mailto:n.griffiths@virgin.net]
Sent: 28 August 2002 13:03
To: Paul Newton
Subject: Re[2]: [SDL] SDL in Visual C++

Hello Paul,

PN> OK I had a look at that. I suspect that the problem is the fact that I
PN> don’t have a main. What sholud I do. As I am developing a GUI I
created my
PN> project as a MFCAppWizard(Exe). How do I set this up so as it will
allow me
PN> to use SDL. I have followed all the steps in the “Using SDL with
Microsoft
PN> Visual C++ 5 and 6” by Lion Kimbro.

You could create a main function that looks something like this:

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

I’ve never tried it as I tend to stay away from MFC as much as
possible, but that might be the solution you’re looking for! Just
remember to link with the SDL libraries…


Best regards,
Neil mailto:n.griffiths at virgin.net


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

Hello Paul,

PN> Where should I create this. What is the AfxMain. WHat else do I need to
PN> do?

AfxMain is the main function in MFC applications. If it isn’t, then
replace the AfxMain() call with whatever your main() function is
named. You can place the main() function that I gave you in the same C
file as where your AfxMain() function would be.–
Best regards,
Neil mailto:n.griffiths at virgin.net

I don’t see anything that syas AfxMain. Where would this be. Might it have
a different name.

Thanks,
Paul> ----- Original Message -----

From: Neil Griffiths [mailto:n.griffiths@virgin.net]
Sent: 28 August 2002 14:43
To: Paul Newton
Subject: Re[4]: [SDL] SDL in Visual C++

Hello Paul,

PN> Where should I create this. What is the AfxMain. WHat else do I need
to
PN> do?

AfxMain is the main function in MFC applications. If it isn’t, then
replace the AfxMain() call with whatever your main() function is
named. You can place the main() function that I gave you in the same C
file as where your AfxMain() function would be.


Best regards,
Neil mailto:n.griffiths at virgin.net


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

Hello Paul,

PN> I don’t see anything that syas AfxMain. Where would this be. Might it have
PN> a different name.

Okay, my bad - it’s probably called AfxWinMain. As I said, I rarely do
any MFC - but I just used the MFC wizard to find it.

However, looking further at it, I see a problem. The actual entry for
a MFC application is:

extern “C” int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE
hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)

I’m not entirely sure how you could pass those parameters to
AfxWinMain() if you have a fake main() function which was my idea.
Well… I think there’s a function called AfxGetInstance() - there
definitely IS a function that does it, but I’m not a MFC coder, I’ve
only come across that at work. So you COULD do it - it’ll just take a
little work.

If you really can’t figure out how to do it, get back to me
privately and I’ll try and help you out, but I think I’ve given you
enough information to be able to get on with it. :slight_smile: Except use
n_griffiths at lineone.net because the account I’m sending this from is
horribly broken!–
Best regards,
Neil mailto:n.griffiths at virgin.net