error LNK2001: 无法解析的外部符号 __imp____iob_func - 小众知识

error LNK2001: 无法解析的外部符号 __imp____iob_func

2021-03-08 08:09:50 苏内容
  标签: LNK2001
阅读:10521

问题描述

在VS2017中使用VS2005编译的lib文件,报链接错误:


error LNK2001: 无法解析的外部符号 __imp____iob_func

分析

在VS2005中,有__imp____iob_func的定义,但在VS2017中被修改了,因为找不到符号。


解决方案

在VS2017工程中做一个转换,将VS2005中低版本的定义转换成VS2017中的高版本定义:


extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }

注:为避免重复定义问题,此段代码最好放在某个cpp文件中,如stdafx.cpp。


VS2019编译OpenSEES时碰到如上问题也可以用如上方法解决


hanks for posting here.

>>Migrating from VS2010 to VS 2017: Getting error __iob_func: identifier not found

In visual studio 2015, stdin, stderr, stdout are defined as follow :

#define stdin  (__acrt_iob_func(0))#define stdout (__acrt_iob_func(1))#define stderr (__acrt_iob_func(2))

But previously, they were defined as:

#define stdin  (&__iob_func()[0])#define stdout (&__iob_func()[1])#define stderr (&__iob_func()[2])

In my opinion, the legacy_stdio_definitions.lib means the previous version of std lib which you linked in your vs2010.

Or you could upgrade your project to vs 2017 by using the visual studio tool. When you first open a Visual C++ project that was created in an earlier version of Visual Studio, you might be prompted to update the project. The message asks whether you want to upgrade to the most recent version of the Visual C++ compiler and libraries.


扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1