问题描述
用vs编写的win32程序,在其他32位电脑上报vcruntime140.dll确实错误。最后将C:\Windows\System32下的vcruntime140.dll拷贝到文件运行目录,结果报0x0000007b错误。
错误原因是程序是32位的,使用64位的dll。解决办法是全部换成32位的dll
问题查找:
使用vs自带的dumpbin工具查看动态库位数。以vs2019为例 搜索 该文件x86_x64 Cross Tools Command Prompt for VS 2019,打开该文件
在命令行下输入dumpbin /headers 目标程序。按下回车键得到结果。
D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>dumpbin /headers C:\Windows\System32\vcruntime140.dll
Microsoft (R) COFF/PE Dumper Version 14.28.29913.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file C:\Windows\System32\vcruntime140.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
8664 machine (x64)
7 number of sections
609DE407 time date stamp Fri May 14 10:44:23 2021
0 file pointer to symbol table
0 number of symbols
F0 size of optional header
2022 characteristics
Executable
Application can handle large (>2GB) addresses
DLL
发现该文件夹下的vcruntime140.dll是64位的。
于是找到C:\Windows\SysWOW64这个文件夹下的vcruntime140.dll看看
D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>dumpbin /headers C:\Windows\SysWOW64\vcruntime140.dll
Microsoft (R) COFF/PE Dumper Version 14.28.29913.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file C:\Windows\SysWOW64\vcruntime140.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (x86)
5 number of sections
604196CE time date stamp Fri Mar 5 10:26:22 2021
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2122 characteristics
Executable
Application can handle large (>2GB) addresses
32 bit word machine
这个文件夹才是32位的。把32位的vcruntime140.dll这个文件拷贝到运行目录即可,程序正常运行。64位库在32位上为什么报这个0x0000007b错误,还不知道,这个需要查一下。