Use vc6.0 to rewrite the whole process from an ANSI project to a unicode Project

Source: Internet
Author: User

Recently, I received a task to rewrite a software version to support the Chinese version. In fact, the idea is very simple. You only need to change the project file from the ANSI version to the Unicode version. However, during the rewrite process, we still encountered some minor problems. Now we can record the entire process so that we can be more convenient in the future. At the same time, if other friends encounter the same problem, we can also solve it, you don't have to find the reason one by one.

 

1. First, open the project-> recompile.

Ensure that the original project is compiled.

2. Open project> setting> C/C ++> Preprocessor definitions to add _ Unicode.

 

Compile again and try again to see what problems occur :)

When compiling to the following line, error c2002: Invalid wide-character constant appears.

  1. Addspecchar (_ T ("& bull;"), _ T ("/x95/0 "));

Solution: Change _ T ("/x95/0") to _ T ("/0x95 ")

3. Re-compile

Error lnk2001: unresolved external symbol _ winmain @ 16

Solution: refer to the third solution mentioned in "fengying haiyi"'s blog: http://blog.chinaunix.net/u1/54017/showart_489195.html.

Solve the external symbol error: _ main, _ winmain @ 16 ,__ beginthreadex
When creating an MFC project without using the MFC Appwizard wizard, many connection errors will be generated during compilation, such as the error lnk2001 error. The typical error prompt is libcmtd. lib (crt0.obj): Error lnk2001: unresolved external symbol _ main
Libcd. Lib (wincrt0.obj): Error lnk2001: unresolved external symbol
Msvcrtd. Lib (crtexew. OBJ): Error lnk2001: unresolved external symbol _ winmain @ 16
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ beginthreadex P
Nafxcwd. Lib (thrdcore. OBJ): Error lnk2001: unresolved external symbol _ endthreadex

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
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 "Link" property page, select output in category, and 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, and select code generation in category, in the use run-time library, select debug multithreaded or multithreaded,
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

 

4. Compile again, and the following occurs:

Warning c4706: Assignment within conditional expression warning.

Solution: Set Project-> setting-> C/C ++ warning level to level 3.

 

5. After compilation, the fatal error lnk1104: cannot open file "mfc42ud. lib" error occurs. You can download the corresponding lib and DLL files.

I have already packaged it in idea

Http://www.fdigg.net/sitelist.aspx? Id = 8a5a0a700a7500bf & dir = 0030109722470f1621a2f99303bbfebb can be downloaded to the entire vc6.0 File

 

6. the final compilation, thank God-0 error (s), 0 warning (s!

 

 

 

 

 

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.