MFC Errors :: C++

Status
Not open for further replies.
Hi.

I am studying MFC from Prosise's book. I read the first three chapters, but have not started implementing any sample until today. Visual C++ output three errors with the "Hello MFC" program.

MFC-Hello error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)

-----

MFC-Hello error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)

-----

MFC-Hello fatal error LNK1120: 2 unresolved externals

-----

Does anyone know what those errors are about? I copied *exactly* what Promise wrote in his book.

Thanks,
Kuphryn
 

earl

Well-known member
3,066
You are using the wrong version of MFC or, more likely, the wrong version of the C++ libs. Go to:
Project->Settings->C/C++ Tab->Category: Code Generation

Switch the run-time library you are using to Multithread. If you are using a MFC DLL (You can tell from the general tab), use the multithreaded DLL. Otherwise, use Multithreaded.

Oh, and use the proper Debug/ non-debug settings depending on if you are doing a debug or release build.

Oh, and make sure that under the General tab, you are using MFC.

-earl-

Edit: and if I remember correctly from that book, he specifies how to setup the project and work with the VS environment. You would do well not to skip that part.
 

earl

Well-known member
3,066
He doesn't mention? That seems strange, given that the default project apparently won't build. Anyway, I'm glad you got it working. Be prepared to see this type of error a lot when doing MFC programming if you use libs you create yourself. One common flag is if you see __beginthreadex undefined, something that should be using multithreaded libs isn't.

-earl-
 
Status
Not open for further replies.