包含arxHeader.h的工程中调用了标准fstream, sstream, iosteam等引发链接问题的解决方案

发布时间:2020-06-16 19:13:16 作者:unicornsir
来源:网络 阅读:810

问题的提出:

        最近在施行多平台编译,原来没有的问题,由于维护多平台而涌现了出来,在其中的一个工程中,用到了fsteam等类库,当初在vs2002中,没有加arxHeader.h编译没问题,由于要向多平台转换,因此加入了arxHeader.h,因为arxHeader.h中把相应的类库引用了进来,而不需要在工程中设置,因此就出现了下面的链接错误:

 

问题的描述:    

error LNK2019: 无法解析的外部符号 "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"

 error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall std::basic_ofstream<char,struct std::char_traits<char> >::basic_ofstream<char,struct std::char_traits<char> >(void)"

 error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall std::basic_ofstream<char,struct std::char_traits<char> >::`vbase destructor'(void)"

 

问题的根源:

        由于知道是加入了arxHeader.h引发的错误,但是为什么会出现这样的错误呢,经过耐心的寻找(二分查错法),最近锁定在了dbColor.h中的内容:

//prevent the MS header "use_ansi.h" from outputing
//its linker directives, we expect clients to specify
//what flavor (debug/release) of the C++ runtime they want to
//link against.
#pragma push_macro("_USE_ANSI_CPP")
#define _USE_ANSI_CPP

#include <vector>

#pragma pop_macro("_USE_ANSI_CPP")


      原来是AutoDesk公司为了防止链接错误,而让用户自己指定相应的类库

问题的解决:

      知道原因就很容易解决问题了,由于本工程是多线程DLL的DEBUG版,故在链接库中添加msvcprtd.lib,编译通过!

推荐阅读:
  1. 再学C++ Primer(8)-标准IO库
  2. C++语言学习(九)——C++标准库简介

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

职场 编译 休闲

上一篇:前后分离的 shiro 权限

下一篇:Android线程池

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》