SDL Forum Index
SDL
Simple DirectMedia Layer Forums
Reply to topic
Re: SDL and MFC
contact access-dev
Guest

Reply with quote
Carlos Alvarez <citrouille <at> wanadoo.fr> writes:

Quote:

Yes you can use SDL within MFC project.

Did you set the projet as a Multithreaded DLL project (Multithreaded Debug
DLL for debug configuration) ?

cya
Carlos

----- Original Message -----
From: "Jeremie" <jeremie.cretegny <at> cpnv.ch>
To: <sdl <at> libsdl.org>
Sent: Monday, January 10, 2005 10:39 AM
Subject: [SDL] SDL and MFC

Quote:
Hello,
I try to use SDL with MS-Visual C++ and MFC.

When I compile the project, I have an unresolved external symbol for the
main
Quote:
function.

The problem is that SDL will a main function and the main function is a
"hidden
Quote:
function" from MFC...

How Can I use MFC AND SDL in the same project???????


Hi,

you can add this code to your program, it works but unfortunalety your program would quit when you close the MFC main windows


int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) {

int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();

if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
goto InitFailure;

if (pApp != NULL && !pApp->InitApplication())
goto InitFailure;

if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
nReturnCode = pThread->Run();

InitFailure:

AfxWinTerm();
SDL_Quit();
return nReturnCode;


}


Quote:
Quote:
_______________________________________________
SDL mailing list
SDL <at> libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl



Yes the project is Multithreadad DLL and the MFC is in shared DLL too.

Since we include SDL library, when we build the project we have this error
during the linking operation:

sdlmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol
_SDL_main

It's normal because we don't have main or WinMain function, it's the MFC who run
the classes.

If we put a main or a WinMain function, we don't have error but it's this main
function that starts the program!

So the question is:
Can we say to SDL that our main function IS the MFC main function?
or
What must we put in the main function for the program boot normally (i think
something like the code of the MFC main function but i'm not sure and i'm not a
pro in MFC...)



Access-Dev.Com
http://www.access-dev.com
Montpellier - France
T?l : +33 (0) 4 67 58 37 90
Fax : +33 (0) 4 67 58 37 90
Mobile : +33 (0) 6 08 16 61 11
SIRET : 482 737 889 00014
Re: SDL and MFC
ibrahim
Guest

Reply with quote
Hi,

you can add this code to your program, it works but unfortunalety your program would quit when you close the MFC main windows


int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) {

int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();

if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
goto InitFailure;

if (pApp != NULL && !pApp->InitApplication())
goto InitFailure;

if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
nReturnCode = pThread->Run();

InitFailure:

AfxWinTerm();
SDL_Quit();
return nReturnCode;


}



Carlos Alvarez <citrouille <at> wanadoo.fr> writes:

Quote:

Yes you can use SDL within MFC project.

Did you set the projet as a Multithreaded DLL project (Multithreaded Debug
DLL for debug configuration) ?

cya
Carlos

----- Original Message -----
From: "Jeremie" <jeremie.cretegny <at> cpnv.ch>
To: <sdl <at> libsdl.org>
Sent: Monday, January 10, 2005 10:39 AM
Subject: [SDL] SDL and MFC

Quote:
Hello,
I try to use SDL with MS-Visual C++ and MFC.

When I compile the project, I have an unresolved external symbol for the
main
Quote:
function.

The problem is that SDL will a main function and the main function is a
"hidden
Quote:
function" from MFC...

How Can I use MFC AND SDL in the same project???????



Quote:
Quote:
_______________________________________________
SDL mailing list
SDL <at> libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl



Yes the project is Multithreadad DLL and the MFC is in shared DLL too.

Since we include SDL library, when we build the project we have this error
during the linking operation:

sdlmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol
_SDL_main

It's normal because we don't have main or WinMain function, it's the MFC who run
the classes.

If we put a main or a WinMain function, we don't have error but it's this main
function that starts the program!

So the question is:
Can we say to SDL that our main function IS the MFC main function?
or
What must we put in the main function for the program boot normally (i think
something like the code of the MFC main function but i'm not sure and i'm not a
pro in MFC...)



Access-Dev.Com
http://www.access-dev.com
Montpellier - France
T?l : +33 (0) 4 67 58 37 90
Fax : +33 (0) 4 67 58 37 90
Mobile : +33 (0) 6 08 16 61 11
SIRET : 482 737 889 00014
Re: SDL and MFC
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic