Treat wchar_t as built-in type不一致导致的链接错误

今天用VS2013新建了一个工程,生成时出现很多怪异的链接错误,比如:

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)

用Notepad2打开导入库xxx.lib,里面确实搜不到__imp_?fromWCharArray@MTString@@SA?AV1@PB_WH@Z,但可以搜到前半部分,网上一搜发现是将“wchar_t视为内置类型”配置不一致导致的。
VS2005之前项目的默认配置是不将wchar_t视为内置类型(即wchar_t 是视作unsigned short的),而从VS2005开始默认是将wchar_t视为内置类型。这导致用VS2005及之后的VS版本升级以前的dll工程时,会和新建的工程在配置上不一致,从而导致链接错误。

MSDN给出了详细的解释:https://msdn.microsoft.com/en-us/library/dh8che7s.aspx

To set this compiler option in the Visual Studio development environment:
1. Open the project's Property Pages dialog box. For details, see Working with Project Properties.
2. In the left pane, expand Configuration Properties, C/C++, and then select Language.
3. Modify the Treat wchar_t as Built-in Type property.

posted on   wu.g.q  阅读(48)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示