Link error caused by inconsistent Treat wchar_t as built-in type, wchar_tbuilt-in

Source: Internet
Author: User

Link error caused by inconsistent Treat wchar_t as built-in type, wchar_tbuilt-in

Today, a new project was created with VS2013, and many weird Link errors were generated, such:

Error LNK2019: unresolved external symbol "_ declspec (dllimport) public: static class MTString _ cdecl MTString: fromWCharArray (wchar_t const *, int)" (_ imp _? FromWCharArray @ MTString @ SA? AV1 @ PB_WH @ Z) referenced in function "public: void _ thiscall MTIO: queryMtInDevices (void )"(? QueryMtInDevices @ MTIO @ QAEXXZ)

Use Notepad2 to open the import warehouse xxx. lib, which does not find _ imp _? FromWCharArray @ MTString @ SA? AV1 @ PB_WH @ Z, but you can search for the first half. On the internet, a search finds that "wchar_t is regarded as a built-in type" is caused by inconsistent configuration.
Before VS2005, the default configuration of the project does not regard wchar_t as the built-in type (that is, wchar_t is regarded as the unsigned short). From VS2005, wchar_t is considered as the built-in type by default. This leads to the configuration inconsistency between the dll project upgraded with VS2005 and later VS versions and the newly created Project, resulting in a link error.

MSDN gives a detailed explanation: https://msdn.microsoft.com/en-us/library/dh8che7s.aspx

To set this compiler option in the Visual Studio development environment:
1. OpenProject's PropertyPages dialog box. For details, see Working with Project Properties.
2. In the left pane, expandConfiguration Properties, C/C ++, And then selectLanguage.
3. ModifyTreat wchar_t as Built-in TypeProperty.

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.