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.