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

 问题的提出:

        最近在施行多平台编译,原来没有的问题,由于维护多平台而涌现了出来,在其中的一个工程中,用到了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,编译通过!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值