【问题标题】:error LNK2019: unresolved external symbol ___iob_func referenced in function "void __cdecl Padding(int)"错误 LNK2019:函数“void __cdecl Padding(int)”中引用的未解析外部符号 ___iob_func
【发布时间】:2014-11-18 07:47:19
【问题描述】:

在 Visual Studio 2012 下使用 FTDI API 编译和链接很好。

但在 VS 2014 下,它给出了:

Error LNK2019: unresolved external symbol ___iob_func referenced in function "void __cdecl Padding(int)"

标准库有变化吗?

【问题讨论】:

    标签: c++ visual-studio visual-studio-2015


    【解决方案1】:

    是的,标准库已经改变,FTDI 似乎并不在意 - 至少在 CDM2.12.18 驱动程序版本中没有。

    this question 的答案中描述了该问题。

    ftd2xx.lib 中的 devcon.obj 中的 void __cdecl Padding(int) 函数是罪魁祸首。它引用stdinstdoutstderr 之一,以宏的形式给出。这些宏的内容发生了变化。

    由于我们并不真正期望 FTDI 库提供任何 I/O,因此我们不妨提供最简单的实现:

    FILE* __cdecl _imp____iob_func() { return 0; }
    

    如果你想要一个能做它应该做的版本:

    FILE* __cdecl _imp____iob_func()
    {
        struct _iobuf_VS2012 { // ...\Microsoft Visual Studio 11.0\VC\include\stdio.h #56
            char *_ptr;
            int   _cnt;
            char *_base;
            int   _flag;
            int   _file;
            int   _charbuf;
            int   _bufsiz;
            char *_tmpfname; };
        // VS2015 has FILE = struct {void* _Placeholder}
    
        static struct _iobuf_VS2012 bufs[3];
        static char initialized = 0;
    
        if (!initialized) {
            bufs[0]._ptr = stdin->_Placeholder;
            bufs[1]._ptr = stdout->_Placeholder;
            bufs[2]._ptr = stderr->_Placeholder;
            initialized = 1;
        }
    
        return (FILE*)&bufs;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-01-13
      • 2011-12-12
      • 1970-01-01
      相关资源
      最近更新 更多