Common Errors in vc6.0. Http://hi.baidu.com/%C8%FD%C9%EE/blog/item/4a756ff2cb6bdb19b07ec5df.html

Source: Internet
Author: User
Libcd. lib (wincrt0.obj): Error lnk2001: unresolved external symbol _ winmain @ 16 error when learning VC ++, we often encounter a link error nkl2001. In general, when a connection error occurs, compilation is successful. There are many causes of connection errors, especially lnk2001 errors, which are often unknown. Generate

Lnk2001 error cause: lnk2001 is caused by an Encoding Error. another lnk2001. caused by compilation and link settings is: "libcd. lib (wincrt0.obj ):

Error lnk2001: unresolved external symbol ", the cause of this error is that the program portal is not set for wwinmaincrtstartup. To identify this error, you must first distinguish Win32 when creating a project.

Application and Win32 console application. They are all programs that work in a 32-bit Windows environment. Win32 application is a common window application. Of course, some interfaces are compared.

Personalization, such as circular and irregular shapes. They are all called guis (Graphics User Interface graphical user interface). We can click the mouse to complete the control. Win32 console application

(Win32 console application) often appears like a MS-DOS window (XP is called a command prompt), we have to enter various commands on the keyboard to use it, or the name is Cui (character user interface

Port ).
The following Link error occurs:
Linking.../subsystem: Windows
Libcd. Lib (wincrt0.obj): Error lnk2001: unresolved external symbol _ winmain @ 16
Debug/testwin.exe: Fatal error lnk1120: 1 unresolved externals
Error executing link.exe.
Solution: Set/subsystem: Windows in project options of project-settings-link.
Change to/subsystem: Console
The entry function of Win32 application is winmain.
The entry function of the Win32 console application is main.
That is to say, if you write a traditional C program, you must establish a Win32 console program, but the default value in VC is Win32 application, so the above-mentioned Link errors often occur.
The difference between Win32 application and Win32 console is that the link parameters in VC are different.
Other types of error lnk2001 errors:
When creating an MFC project, the MFC Appwizard wizard is not used. If the project parameters are not set, many connection errors will be generated during compilation, such as error lnk2001. Typical error prompts include:
Libcmtd. Lib (crt0.obj): Error lnk2001: unresolved external symbol _ main
Libcd. Lib (wincrt0.obj): Error lnk2001: unresolved external symbol _ winmain @ 16
Msvcrtd. Lib (crtexew. OBJ): Error lnk2001: unresolved external symbol _ winmain @ 16
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ beginthreadex
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ endthreadex
The solution is as follows:
1. Windows subsystem setup error, prompt:
Libcmtd. Lib (crt0.obj): Error lnk2001: unresolved external symbol _ main
For Windows projects, you must use the Windows subsystem instead of the console. You can set it as follows:
[Project] --> [settings] --> select the "Link" property page,
Change/subsystem: console to/subsystem: Windows in project options.
2. the console subsystem settings are incorrect. The following message is displayed:
Libcd. Lib (wincrt0.obj): Error lnk2001: unresolved external symbol _ winmain @ 16
For a console project, use the console subsystem instead of windows. Set:
[Project] --> [settings] --> select the "Link" property page,
Change/subsystem: Windows to/subsystem: console in project options.
3. The program entry settings are incorrect. The prompt is:
Msvcrtd. Lib (crtexew. OBJ): Error lnk2001: unresolved external symbol _ winmain @ 16
Generally, the program entry function of the MFC project is winmain. If the Unicode version of the project is compiled, the program entry must be changed to wwinmaincrtstartup. Therefore, you need to reset the program entry:
[Project] --> [settings] --> select the "C/C ++" attribute page,
In category, select output,
Enter wwinmaincrtstartup in entry-point symbol.
4. When the thread is running, the database settings are incorrect. The prompt is:
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ beginthreadex
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ endthreadex
This is because when MFC uses a multi-threaded library, you need to change the settings:
[Project] --> [settings] --> select the "C/C ++" attribute page,
In category, select code generation,
Select debug multithreaded or multithreaded in the use run-time library.
Where,
Single-threaded single-thread static link library (Release Version)
Multithreaded multi-thread static link library (Release Version)
Multithreaded DLL multi-thread dynamic link library (Release Version)
Debug single-threaded single-thread static link library (debug version)
Debug multithreaded multi-thread static link library (debug version)
Debug multithreaded DLL multi-thread dynamic link library (debug version)
Single thread: When multi-thread calling is not required, it is usually used in DOS environments.
Multithreading: Concurrent Operation
Static Library: link the library directly with the program and run it without the MFC library.
Dynamic library: The corresponding DLL dynamic library is required for the program to run.
Release Version: used for official release
Debug version: used during debugging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.