Jump to content
  • Advertisement
Sign in to follow this  
JohnsonGPS

afx.h causes trouble

This topic is 4235 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I created a Win32 Console project with Microsoft Visual C++.NET. After I added #include <afx.h>, I got the following error message. Does it mean that I cannot use afx.h in Win32 Console project? ProcessLogs error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z) ProcessLogs 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) ProcessLogs fatal error LNK1120: 2 unresolved externals Thanks. Johnson #include "stdafx.h" #include <afx.h> int _tmain(int argc, _TCHAR* argv[]) { return 0; }

Share this post


Link to post
Share on other sites
Advertisement
it means you're not linking to the correct library. You need to link to whatever library defines the symbols declared via afx.h. check msdn for documentation for which libs you need.

-me

Share this post


Link to post
Share on other sites
In order to use these thread functions, you need to link to the multithreaded version of the C runtime library.

Project > Properties > C/C++ > Code Generation > Runtime Library. Change from whichever single threaded version you are currently using to the corresponding multithreaded version.

Share this post


Link to post
Share on other sites

After switching from single threaded Runtime library to the multithreaded one, I got the following error.

ProcessLogs warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
ProcessLogs error LNK2001: unresolved external symbol ___argvProcessLogs error LNK2001: unresolved external symbol ___argc
ProcessLogs fatal error LNK1120: 3 unresolved externals


Johnson


#include "stdafx.h"
#include "afx.h"

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}


____________________________________________________________________________

In order to use these thread functions, you need to link to the multithreaded version of the C runtime library.

Project > Properties > C/C++ > Code Generation > Runtime Library. Change from whichever single threaded version you are currently using to the corresponding multithreaded version.

Share this post


Link to post
Share on other sites
This code:


#include "afx.h"

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}



compiles and links fine for me, using VS 2003. All I did was create a new, empty console project, and switch to use the multithreaded CRT.

What else do you have in your project?
What are the contents of your "stdafx.h"?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!