unresolved external symbol __imp____acrt_iob_func linking error

huangapple go评论104阅读模式
英文:

unresolved external symbol __imp____acrt_iob_func linking error

问题

尝试编译 zlib 1.2.13 以供 Windows 使用。
无法解决下面的链接错误,请提供任何帮助!

创建库 zdll.lib 和对象 zdll.exp

[2023-08-09T07:50:09.645Z] 如果存在 zlib1.dll.manifest  mt -nologo -manifest zlib1.dll.manifest -outputresource:zlib1.dll;2

[2023-08-09T07:50:10.227Z] cl -c -I. -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_NO_CRT_STDIO_INLINE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib"  ./test\example.c

[2023-08-09T07:50:10.227Z] example.c

[2023-08-09T07:50:10.227Z] link -nologo -debug -incremental:no -opt:ref example.obj zlib.lib

[2023-08-09T07:50:10.227Z] example.obj : error LNK2019: unresolved external symbol __imp____acrt_iob_func referenced in function _main

[2023-08-09T07:50:10.227Z] example.exe : fatal error LNK1120: 1 unresolved externals

[2023-08-09T07:50:10.227Z] NMAKE : fatal error U1077: '"c:\program files (x86)\microsoft visual studio 12.0\vc\bin\link.EXE"' : return code '0x460'

[2023-08-09T07:50:10.227Z] 停止。

我的库环境变量:

$env:lib += ";c:\program files (x86)\microsoft visual studio 12.0\vc\lib"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\um\x86"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\um\x64"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\ucrt\x86"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\ucrt\x64"
$env:lib += ";c:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\VC\Tools\MSVC.29.30133\lib\x86"
$env:lib += ";c:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\VC\Tools\MSVC.29.30133\lib\x64"
英文:

Trying to compile zlib 1.2.13 for windows.
Cannot resolve linker error below, any help is appreciated!

Creating library zdll.lib and object zdll.exp

[2023-08-09T07:50:09.645Z] 	if exist zlib1.dll.manifest  mt -nologo -manifest zlib1.dll.manifest -outputresource:zlib1.dll;2

[2023-08-09T07:50:10.227Z] 	cl -c -I. -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_NO_CRT_STDIO_INLINE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib"  ./test\example.c

[2023-08-09T07:50:10.227Z] example.c

[2023-08-09T07:50:10.227Z] 	link -nologo -debug -incremental:no -opt:ref example.obj zlib.lib

[2023-08-09T07:50:10.227Z] example.obj : error LNK2019: unresolved external symbol __imp____acrt_iob_func referenced in function _main

[2023-08-09T07:50:10.227Z] example.exe : fatal error LNK1120: 1 unresolved externals

[2023-08-09T07:50:10.227Z] NMAKE : fatal error U1077: '"c:\program files (x86)\microsoft visual studio 12.0\vc\bin\link.EXE"' : return code '0x460'

[2023-08-09T07:50:10.227Z] Stop.

my lib environment variables:

$env:lib += ";c:\program files (x86)\microsoft visual studio 12.0\vc\lib"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\um\x86"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\um\x64"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\ucrt\x86"
$env:lib += ";c:\program files (x86)\windows kits\lib.0.19041.0\ucrt\x64"
$env:lib += ";c:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\VC\Tools\MSVC.29.30133\lib\x86"
$env:lib += ";c:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\VC\Tools\MSVC.29.30133\lib\x64"

答案1

得分: 1

总的来说,使用不同版本的Visual C++编译器构建的代码通常不具备链接兼容性。有特定情况下它可以工作,但主要是导入使用C ABI的DLL的库(例如“KERNEL32.LIB”等)。

Visual C++团队一直在努力支持从VS 2015 Update 3到VS 2022的“前向链接兼容性”。请参阅Microsoft Learn。VS 2013不包括在此承诺范围内。

你应该考虑使用像VCPKG这样的包管理器来获取zlib,以确保你使用了匹配的编译器工具集。

英文:

In general, code built with different versions of the Visual C++ compiler are not link-compatible. There are specific cases where it works, but mostly just import libraries for DLLs using the C ABI (i.e. stuff like KERNEL32.LIB, etc.)

The Visual C++ team has been working really hard to support 'forward link compatibility' for VS 2015 Update 3 - VS 2022. See Microsoft Learn. VS 2013 is NOT part of this promise.

You should look at using a package manager like VCPKG for zlib which ensures you are using the matching compiler toolset.

huangapple
  • 本文由 发表于 2023年8月9日 18:42:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76866980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定