Friday, October 29, 2010

Error LNK2001: unresolved external symbol vc++ c++ error message

When compiling an MFC application using the single-threaded run-time library, you receive the following two unresolved external error messages:

nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__beginthreadex"


nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__endthreadex"

Starting with version 3.0, all MFC classes are "thread safe" and require the multi-threaded run-time libraries to link successfully. Many people try to use the single-threaded run-time libraries because they assume these libraries are needed to enable the application to run in Win32s. This is not the case. MFC versions 3.0 and later will use a single thread, so as long as you are not creating additional threads in the application, the application will run under Win32s.

To avoid these unresolved external errors, do not set the Project Settings to Single-Threaded for an MFC version 3.0 or later application. This setting can be changed by doing the following:

On Microsoft Visual C++ .NET 2003

1. Click the Project menu.
2. Click Properties.
3. Expand Configuration Properties, and then click C/C++.
4. Click Code Generation.
5. In the right pane, make a selection other than Single-threaded or Single-threaded Debug in the Runtime Library list.

On Microsoft Visual C ++ 2.x, 5.0, and 6.0

1. Select the Project menu.
2. Select the Settings... option.
3. Select the C/C++ tab.
4. Select Code Generation on the Category list box.
5. Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.

On Microsoft Visual C++ 4.x

1. Select the Build menu.
2. Select the Settings... option.
3. Select the C/C++ tab.
4. Select Code Generation on the Category list box.
5. Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.

No comments:

Post a Comment