专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Visual Studio

Treat wchar_t as built-in type不一致导致的链接异常

发布时间:2011-06-23 13:54:27 文章来源:www.iduyao.cn 采编人员:星星草
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.

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: