Skip to main content
 首页 » 编程设计

python之在 GDB python 接口(interface)下导入 wx 失败,R6034 : An application has made an attempt to load the C runtime library incorrectly

2025年05月04日24jirigala

我有一个自建的GDB.exe在 WinXP 下,这是针对 python 2.7 的链接dll。 GDB 是在 msys+MinGW 下构建的,所以 GDB.exe链接到 msvcrt.dll .但是 python dll 链接到 msvcrt90.dll .请参阅下面的 dependency walker 屏幕截图。 一般GDB.exe中的python解释器工作得很好,我可以正确运行 python pretty-print 和其他 python 命令。 但是我发现wxPython不能正常运行,查看命令日志:

GNU gdb (GDB) 7.8.50.20140717-cvs 
Copyright (C) 2014 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law.  Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "mingw32". 
Type "show configuration" for configuration details. 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
Find the GDB manual and other documentation resources online at: 
<http://www.gnu.org/software/gdb/documentation/>. 
For help, type "help". 
Type "apropos word" to search for commands related to "word". 
(gdb) python import wx 
Traceback (most recent call last): 
  File "<string>", line 1, in <module> 
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\__init__.py", li 
ne 45, in <module> 
    from wx._core import * 
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\_core.py", line 
4, in <module> 
    import _core_ 
ImportError: DLL load failed: The specified module could not be found. 
Error while executing Python code. 
(gdb) 

我意识到文件夹下有一些dll:E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx ,例如 "core_.pyd"和 "wxmsw30u_core_vc90.dll" ,这些 dll 是从 Visual C++ 构建的,您可以看到,它们链接到 msvcr90.dll和 msvcp90.dll .

但如果我在 python.exe(即 E:\code\gdb\mybuild\bin\python.exe)命令行 shell 下运行相同的命令,则不会出现此类问题,请查看日志:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 
32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import wx 
>>> 

看,我没有任何问题可以运行 import wx命令。 我还注意到 python.exe是针对 msvc90.dll 构建的,请参阅下面的依赖项 walker 屏幕截图:

现在,我的问题是:如何解决这个问题?据我所知,这两种不同类型的 DLL(msvcrt.dll 和 msvcrt90.dll)工作正常,但为什么我不能使用 wxpython?谢谢。

请您参考如下方法:

OK,问题解决。原因是E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx文件夹下的pyd文件和dll文件都需要关联与 list 。我通过名为 Resource Hacker 的工具手动将 list 添加到 pyd 文件中, 但我认为任何可以编辑 PE 文件的工具都可以做到这一点。 pyd 文件已经有一些 list ,所以我只添加更多:

<dependency> 
<dependentAssembly> 
  <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> 
</dependentAssembly> 
</dependency> 

对于dll文件,我刚刚在一个wxpython开发包中找到manifest文件32-bit binaries for MSVC 9来自官方 wxPython 站点,所以我只是将 list 文件复制到 E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx。

我现在没有问题,我可以从 GDB 的命令行正确显示 wxFrame。