在 Cygwin/GCC C 中嵌入 Windows Python程序

发布于 2024-08-02 09:24:21 字数 1064 浏览 2 评论 0原文

我目前正在开发一个用 C++ 编写的 Cygwin/GCC 应用程序。该应用程序需要嵌入 python 来运行插件,我已经使用 Cygwin python 库成功嵌入,并且能够作为程序的一部分运行简单的 python 文件。但是,Python文件现在需要使用Windows GUI框架(wxPython),因此我需要能够嵌入Windows Python环境,否则我无法在Python文件中使用该框架。为了尝试做到这一点,我使用 这些说明的步骤 2 创建了 libpython25.a 。然后我使用 Windows 安装的库/头文件来编译它。然而,当我运行它时,程序崩溃并出现一些奇怪的调试器输出(调试信息打开,很奇怪)。

gdb: unknown target exception 0xc0000008 at 0x77139a13
Program received signal ?, Unknown signal.
[Switching to thread 2216.0x119c]
0x77139a13 in ntdll!RtlLockMemoryZone () from /cygdrive/c/Windows/system32/ntdll.dll
(gdb) where
#0  0x77139a13 in ntdll!RtlLockMemoryZone () from /cygdrive/c/Windows/system32/ntdll.dll
#1  0x030c1c7c in ?? ()
#2  0x030c1c80 in ?? ()
#3  0x1e0d0e80 in python25!_PyTime_DoubleToTimet ()
   from /cygdrive/c/Windows/SysWOW64/python25.dll
#4  0x00000000 in ?? ()'

如果有人成功地做到了这一点,我将非常感谢您的帮助。是否可以将 Windows python 嵌入到 Cygwin/GCC 程序中?如果不是,我还有其他选择吗? (现在我只能考虑转向 VC++,但这将是相当激烈的,而且我不想使用 X11 作为 GUI)。

I am currently working on a Cygwin/GCC application written in C++. The application requires embedding of python to run plug-ins, I've successfully embedded using the Cygwin python libraries and was able to run simple python files as part of the program. However, the python files now require the use of a windows GUI framework (wxPython), and so I need to be able to embed the Windows Python environment, otherwise I cannot use the framework in the python files. In an attempt to do this, I created libpython25.a using step 2 of these instructions. I then used the library/header files of the windows installation to compile it. However, when I run it the program crashes with some strange debugger output (debug info is on, strangely enough).

gdb: unknown target exception 0xc0000008 at 0x77139a13
Program received signal ?, Unknown signal.
[Switching to thread 2216.0x119c]
0x77139a13 in ntdll!RtlLockMemoryZone () from /cygdrive/c/Windows/system32/ntdll.dll
(gdb) where
#0  0x77139a13 in ntdll!RtlLockMemoryZone () from /cygdrive/c/Windows/system32/ntdll.dll
#1  0x030c1c7c in ?? ()
#2  0x030c1c80 in ?? ()
#3  0x1e0d0e80 in python25!_PyTime_DoubleToTimet ()
   from /cygdrive/c/Windows/SysWOW64/python25.dll
#4  0x00000000 in ?? ()'

If anyone has done this successfully, I would greatly appreciate the help. Is embedding Windows python in a Cygwin/GCC program possible? If not what are my other options? (Right now I can only think of moving over to VC++ but this would be pretty drastic, also I do not want to use X11 for the GUI).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情深已缘浅 2024-08-09 09:24:21

这不是一个直接的答案,但您可以将系统分成 2 个进程 - Cygwin 进程(Python 和 C++,无 wxPython)和 win32 进程(Python 和 wxPython),并使用 RPyC、XML-RPC 等。

Not a direct answer, but you could split the system into 2 processes - the Cygwin one (Python & C++, no wxPython) and the win32 one (Python & wxPython) and communicate between them with RPyC, XML-RPC, etc.

我ぃ本無心為│何有愛 2024-08-09 09:24:21

看来您的 32 位/64 位不匹配。

您正在 64 位计算机上运行代码(因为有 SysWow64 文件夹),但我的猜测是您的 python25.dll 是 32 位的。令人困惑的是“system32”包含 64 位 DLL。

+我认为调试没有打开,你只能看到公共符号。

It looks like you have a 32 bit / 64 bit mismatch.

You are running code on a 64bit machine (because there is a SysWow64 folder), but my guess is that your python25.dll is 32 bit. What is confusing is that "system32" contains 64 bit DLLs.

+I don't think debug is on, you only see the public symbols.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文