包含arxHeader.h的工程中调用了标准fstream, sstream, iosteam等引发链接问题的解决方案
2011-10-18 15:00
316 查看
问题的提出:
最近在施行多平台编译,原来没有的问题,由于维护多平台而涌现了出来,在其中的一个工程中,用到了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,编译通过!
最近在施行多平台编译,原来没有的问题,由于维护多平台而涌现了出来,在其中的一个工程中,用到了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,编译通过!
相关文章推荐
- IOS开发笔记之五——Xcode 6.0 Beta编译工程时可能遇到的问题及参考解决方案
- 关于在工程中多次包含库文件引发的问题
- easyui的tab标签链接aspx页面引发全局刷新的问题解决方案
- jnative在linux下对c程序的动态链接库的调用问题及解决方案
- Xcode 4 引入工程后引发的“ header files not found”问题的解决方法
- iOS 工程中调用设备拍照等官方功能时操作语言为英文的解决方案
- jnative在linux下对c程序的动态链接库的调用问题及解决方案
- 问题:IOS懒加载不调用的解决方案
- “error PRJ0050: 未能注册输出。请确保您有修改注册表的相应权限。” 上网找了一下次问题的解决方案 工程设置的问题,VS2005建的STL工程中默认的设置是: ALT的使用:动态链接到 A
- 问题:IOS懒加载不调用的解决方案
- cocos2d 工程移植到iOS碰到的一些问题解决方案
- 【IOS】工程编译中常见问题
- 关于c#调用c++ dll 的一些问题和解决方案
- ios关于dealloc 不调用的问题
- ios 写项目的时候遇到的问题及解决方案
- 一个关于WCF调用远程链接返回405错误不允许使用此方法的问题
- C++中动态内存分配引发问题的解决方案
- 兼容iOS 10 升级xcode8出现的问题及一些适配问题的解决方案
- ios 调用相机 上传图片到服务器 图片角度问题
- 在同一个解决方案下,如何从一个工程中调用另外一个工程的函数