关于run-time error:The thread has exited with code :1073741701 (0xc000007b)

本文介绍了一种常见的VC6.0编译的Win32控制台应用程序在64位系统上运行时出现的运行时错误0xc000007b,并详细解释了解决这一问题的具体步骤。
部署运行你感兴趣的模型镜像

这两天被一个问题搞得吃不下饭,睡不着觉,具体见下图:



此工程用VC6.0编辑,machine环境为64-bit,工程是win32-console application,编译链接均正常,但是运行时出现run-time error:

The thread has exited with code :1073741701 (0xc000007b)


于是我就百度之,一看都是说DirectX9.0出了问题,那么我就重装DirectX9.0,显然不行。


要说还是google靠谱,查询的问题总能有人提问,完美的契合,并做了很好的解答。于是我得知这是一个Win32的工程,但是在链接系统DLL的时候,却链接了64位的DLL。


这里要讲明,Windows下的系统DLL库位于C:\Windows\system32&syswow64下,但这里有一个巨坑,那就是,syswow64里面的DLL都是32位的,在Win32可执行文件链接DLL的时候,Windows会自动链接到syswow64中进行查找。


于是乎,好啊,我就看看该可执行文件到底依赖了哪些DLL,这里推荐使用一个工具Dependency Walker,他可以查看该exe文件依赖了哪些动态库。于是我就将那些检索不到的DLL都下载下来,放到可执行文件同一目录下(这里推荐脚本之家网站查找DLL,很全面且绿色无广告),但是始终会报如下错误:

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

这是我想起来google上的老外说的,可能是这个32位的exe尝试去链接了64位的DLL,但是二者是有差异的,所以有些函数找不到定义,于是我就去syswow64里面查看到底哪些DLL是64位的,这里推荐一个工具,挺好用的,可以判断DLL是32位的还是64位的。

http://www.xdowns.com/soft/6/56/2015/Soft_146958.html(声明作者为:x1688@163.com)


这样我就检测到了msvcr100d.dll这个动态库是64位的,于是去脚本之家下载个32位的,完美解决!(这时我才想起来,昨天打开exe时,说缺失msvcr100d.dll,我一想系统是64位的,就下了个64位的放里面,哎,作死啊)

您可能感兴趣的与本文相关的镜像

Dify

Dify

AI应用
Agent编排

Dify 是一款开源的大语言模型(LLM)应用开发平台,它结合了 后端即服务(Backend as a Service) 和LLMOps 的理念,让开发者能快速、高效地构建和部署生产级的生成式AI应用。 它提供了包含模型兼容支持、Prompt 编排界面、RAG 引擎、Agent 框架、工作流编排等核心技术栈,并且提供了易用的界面和API,让技术和非技术人员都能参与到AI应用的开发过程中

(base) C:\Users\XC>pip install dlib==19.7.0 Collecting dlib==19.7.0 Using cached dlib-19.7.0.tar.gz (4.0 MB) Preparing metadata (setup.py) ... done Building wheels for collected packages: dlib DEPRECATION: Building 'dlib' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'dlib'. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for dlib (setup.py) ... error error: subprocess-exited-with-error &times; python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [76 lines of output] C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py:360: SyntaxWarning: invalid escape sequence '\(' major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0] C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py:361: SyntaxWarning: invalid escape sequence '\(' minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0] C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py:362: SyntaxWarning: invalid escape sequence '\(' patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0] C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py:72: DeprecationWarning: Use shutil.which instead of find_executable _cmake_path = find_executable("cmake") running bdist_wheel running build Detected Python architecture: 64bit Detected platform: win32 Configuring cmake ... D:\Anaconda\Lib\subprocess.py:1029: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used self.stdout = io.open(c2pread, 'rb', bufsize) Traceback (most recent call last): File "<string>", line 2, in <module> exec(compile(''' ~~~~^^^^^^^^^^^^ # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<32 lines>... exec(compile(setup_py_code, filename, "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ''' % ('C:\\Users\\XC\\AppData\\Local\\Temp\\pip-install-t9ptlaxa\\dlib_04710a2f6a364c8391ea5e7017c308fb\\setup.py',), "<pip-setuptools-caller>", "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<pip-setuptools-caller>", line 35, in <module> File "C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py", line 616, in <module> setup( ~~~~~^ name='dlib', ^^^^^^^^^^^^ ...<40 lines>... ], ^^ ) ^ File "D:\Anaconda\Lib\site-packages\setuptools\__init__.py", line 108, in setup return distutils.core.setup(**attrs) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\core.py", line 184, in setup return run_commands(dist) File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\core.py", line 200, in run_commands dist.run_commands() ~~~~~~~~~~~~~~~~~^^ File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\dist.py", line 970, in run_commands self.run_command(cmd) ~~~~~~~~~~~~~~~~^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\dist.py", line 945, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\dist.py", line 989, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "D:\Anaconda\Lib\site-packages\setuptools\command\bdist_wheel.py", line 373, in run self.run_command("build") ~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command self.distribution.run_command(command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\dist.py", line 945, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Anaconda\Lib\site-packages\setuptools\_distutils\dist.py", line 989, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py", line 410, in run self.build_dlib() ~~~~~~~~~~~~~~~^^ File "C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py", line 567, in build_dlib if run_process(cmake_cmd): ~~~~~~~~~~~^^^^^^^^^^^ File "C:\Users\XC\AppData\Local\Temp\pip-install-t9ptlaxa\dlib_04710a2f6a364c8391ea5e7017c308fb\setup.py", line 303, in run_process while t.isAlive(): ^^^^^^^^^ AttributeError: 'Thread' object has no attribute 'isAlive'. Did you mean: 'is_alive'? [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
07-04
<think>我们正在处理一个VC++程序崩溃的问题,错误代码是-1073741701 (0xC000007B)。这个错误通常表示应用程序无法启动,因为它无法加载某个依赖项(如DLL)或者加载的DLL是32位/64位不匹配。 根据错误代码0xC000007B,它代表STATUS_INVALID_IMAGE_FORMAT,即“{错误的图像} %hs 不是有效的 Win32 应用程序。”。这通常发生在尝试加载一个针对不同架构(如32位或64位)的DLL或可执行文件时。 解决方案可能包括: 1. 确保所有DLL都是针对正确的平台(32位或64位)编译的,并且与应用程序的架构匹配。 2. 使用Dependency Walker(depends.exe)来检查应用程序的依赖项,看是否有缺失的DLL或架构不匹配的DLL。 3. 检查是否需要安装Visual C++运行库,并且确保安装的版本与应用程序编译时使用的版本匹配。 4. 如果是64位系统,注意32位程序需要32位的DLL,并且应放在SysWOW64目录下,而64位程序则需要64位的DLL,放在System32目录下。但通常不建议手动放置DLL,而是通过安装相应的运行库来解决。 步骤: 1. 确认应用程序(Apps.exe)是32位还是64位。可以在Visual Studio的项目设置中查看(配置属性 -> 平台)。 2. 使用Dependency Walker打开Apps.exe,查看是否有标记为64位(如果应用程序是32位)的DLL,或者红色的条目(表示缺失DLL)。 3. 确保安装了正确版本的Visual C++运行库。可以从微软官网下载并安装。 另外,根据错误代码0xC000007B,有时候也可能是由于DirectX组件缺失或损坏导致,特别是当应用程序使用DirectX时。可以尝试安装最新版本的DirectX运行时,或者使用DirectX修复工具。 总结步骤: - 检查依赖项(使用Dependency Walker) - 安装正确的VC++运行库(如vcredist_x86或vcredist_x64,根据应用程序的架构选择) - 修复或安装DirectX(使用DirectX修复工具) 注意:由于问题发生在调试版本(Debug\Apps.exe),还需要确保调试环境正确配置,并且所有必要的调试版本的DLL(如MSVCPxxxD.dll,MSVCRxxxD.dll)存在。但通常这些在安装Visual Studio时已经配置好。 如果以上方法无效,可以尝试重新构建解决方案,或者修复Visual Studio安装。 相关问题: 1. 如何确定一个可执行文件是32位还是64位? 2. 如何使用Dependency Walker检查DLL依赖? 3. 如何下载和安装Visual C++运行库? 4. 如何修复DirectX组件? </think>以下是针对VC++程序 `D:\MT_Apps\Apps\Debug\Apps.exe` 以代码 `-1073741701 (0xC000007B)` 退出的解决方案: ### 原因分析 错误代码 `0xC000007B` 表示 **STATUS_INVALID_IMAGE_FORMAT**,通常由以下原因引起: 1. **32位/64位不匹配**:应用程序或依赖的DLL与系统架构不兼容(如64位系统调用32位DLL或反之)[^1] 2. **损坏的运行库**:VC++运行时库(如`msvcp140.dll`, `vcruntime140.dll`) 缺失或版本错误 3. **DirectX组件问题**:图形相关依赖(如`d3dx9_XX.dll`, `XInput1_4.dll`) 异常 4. **系统文件损坏**:Windows系统核心文件被破坏 --- ### 解决方案 #### 第一步:检查架构兼容性 1. 确认应用程序编译平台: - 在Visual Studio中检查项目属性 → **配置属性 → 平台**(需与操作系统匹配) - 若系统为64位,尝试编译为 **x64** 而非 **Win32** 2. 使用 **Dependency Walker** 检查依赖项: - 下载并运行 [Dependency Walker](https://www.dependencywalker.com/) - 打开`Apps.exe`,检查标记为**红色**(缺失)或**黄色**(架构不匹配)的DLL #### 第二步:修复运行库 1. 安装最新VC++运行库: - [Microsoft Visual C++ 可再发行程序包最新版](https://aka.ms/vs/17/release/vc_redist.x64.exe)(64位) - [Microsoft Visual C++ 可再发行程序包最新版](https://aka.ms/vs/17/release/vc_redist.x86.exe)(32位) 2. 修复现有运行库: ```cmd :: 以管理员身份运行CMD sfc /scannow :: 扫描系统文件 DISM /Online /Cleanup-Image /RestoreHealth :: 修复系统映像 ``` #### 第三步:检查图形组件 1. 安装最新 **DirectX End-User Runtime**: - [微软DirectX最终用户运行时下载](https://www.microsoft.com/download/details.aspx?id=35) 2. 修复缺失的D3DX文件: - 使用 **DirectX Repair** 工具自动修复:[下载链接](https://www.zhangduo.com/dxrepair.html) #### 第四步:高级调试 1. 使用 **Process Monitor** 监控文件加载: - 运行ProcMon → 筛选`Apps.exe` → 观察`NAME NOT FOUND`或`WRONG ARCHITECTURE`错误 2. 检查事件查看器日志: - 打开 **事件查看器** → Windows日志 → 应用程序 - 查找与`Apps.exe`相关的错误事件 --- ### 预防措施 - 发布程序时使用 **静态链接**(项目属性 → C/C++ → 代码生成 → 运行库:`/MT`) - 通过 **安装程序** 自动部署VC++运行库(如Inno Setup中集成`vcredist_xXX.exe`) - 使用 **DLL依赖扫描工具**(如[Dependencies](https://github.com/lucasg/Dependencies))提前检测兼容性 > 注:若问题仍存在,请提供**Dependency Walker分析截图**或**事件查看器错误详情**以便进一步诊断[^3]。 ---
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值