解决链接错误:error LNK2001: 无法解析的外部符号 __iob
2014-01-28 15:17
507 查看
该错误主要是由于静态库在VC6编译而主程序在VC2005编译,大家用的CRT不同。解决办法,代码中增加
#ifdef __cplusplus
extern "C"
#endif
FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};
此错误的产生根源:
在VC6的stdio.h之中有如下定义
_CRTIMP extern FILE _iob[];
#define stdin (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])
stdin、stdout、stderr是通过查_iob数组得到的。所以,VC6编译的程序、静态库只要用到了printf、scanf之类的函数,都要链接_iob数组。
而在vc2005中,stdio.h中变成了
_CRTIMP FILE * __cdecl __iob_func(void);
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
_iob数组不再是显式的暴露出来了,需要调用__iob_func()函数获得。所以vc6的静态库链接VC2005的C运行库就会找不到_iob数组.
通过重新定义
FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};
就把vc6需要用到的_iob数组搞出来了
#ifdef __cplusplus
extern "C"
#endif
FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};
此错误的产生根源:
在VC6的stdio.h之中有如下定义
_CRTIMP extern FILE _iob[];
#define stdin (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])
stdin、stdout、stderr是通过查_iob数组得到的。所以,VC6编译的程序、静态库只要用到了printf、scanf之类的函数,都要链接_iob数组。
而在vc2005中,stdio.h中变成了
_CRTIMP FILE * __cdecl __iob_func(void);
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
_iob数组不再是显式的暴露出来了,需要调用__iob_func()函数获得。所以vc6的静态库链接VC2005的C运行库就会找不到_iob数组.
通过重新定义
FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};
就把vc6需要用到的_iob数组搞出来了
相关文章推荐
- 解决链接错误:error LNK2001: 无法解析的外部符号 __iob
- 解决链接错误:error LNK2001: 无法解析的外部符号 __iob
- 解决链接错误:error LNK2001: 无法解析的外部符号 __iob
- 解决链接错误:error LNK2001: 无法解析的外部符号 __iob
- 解决MFC COM组件开发链接错误error LNK2001: 无法解析的外部符号 _CStdStubBuffer2_Release@4
- 使用NetCDF库时提示无法链接错误"error LNK2001: 无法解析的外部符号 nc_create"
- log4cplus使用过程中“LOG4CPLUS_WARN”: 找不到标识符和无法解析的外部符号(链接错误)的解决方法
- vs2015编译ffmpeg 出现错误rtmp.lib(rtmp.obj) : error LNK2001: 无法解析的外部符号 ___iob_func
- c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法
- QT中添加Q_OBJECT时编译提示obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const错误解决方法
- vs2015编译ffmpeg 出现错误rtmp.lib(rtmp.obj) : error LNK2001: 无法解析的外部符号 ___iob_func
- 编译使用 libmp4v2库 libmp4v2.lib(atom_tkhd.obj) : error LNK2001: 无法解析的外部符号 _gettimeofday 错误解决办法.
- c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法
- c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法
- vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject等错误
- OpenCv在win下静态库的编译和使用,以及部分无法解析外部符号的错误解决
- Error LNK2001 无法解析的外部符号 的几种情况及解决办法
- error LNK2001: 无法解析的外部符号 解决办法
- [VS2013]C++中调用Python脚本提示 error LNK2001: 无法解析的外部符号__imp_PyString_FromString等错误的解决方案
- 错误 1 error LNK2001: 无法解析的外部符号 "unsigned int __cdecl Read_Position(void *)" (?Read_Position@@YAIPAX@Z