在 32 位模式下运行 OS X 通用二进制文件

发布于 2024-08-09 08:06:08 字数 433 浏览 3 评论 0原文

我有一个第三方库(Xerox 有限状态工具的接口),它作为通用二进制文件提供,内部有两个变体:PPC 和 i386 变体。我还有一个该库的 Python 接口(使用 ctypes)。

但是,当我尝试运行 Python 界面提供的示例代码时,出现错误,抱怨该库的架构错误:

ImportError: dlopen(/Users/arne/sw/lib/libxcfsm.dylib, 10): no合适的图像成立。找到了:
/Users/arne/sw/lib/libxcfsm.dylib:mach-o,但架构错误

据我所知,这是因为除了我的库中的两个版本之外,python 可执行文件内部还有一个 x86_64 变体,并且更喜欢在该模式下运行。对于某些脚本,我是否有某种方法可以强制 python 可执行文件启动 i386 版本而不是 x86_64 版本?

I have a third-party library (the interface to Xerox's Finite State tools) which come as universal binaries with two variants internally: a PPC and an i386 variant. I also have a Python interface to the library (which uses ctypes).

But when I try to run the example code provided with the Python interface I get an error complaining about the library being the wrong architecture:

ImportError: dlopen(/Users/arne/sw/lib/libxcfsm.dylib, 10): no suitable image found. Did find:
/Users/arne/sw/lib/libxcfsm.dylib: mach-o, but wrong architecture

From what I can gather, this is because the python executables have an x86_64 variant internally in addition to the two versions in my library, and prefer to run in that mode. Is there some way for me to force the python executable to start the i386 version rather than the x86_64 one, for just some scripts?

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

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

发布评论

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

评论(2

二货你真萌 2024-08-16 08:06:08

如果您使用的是苹果系统Python(在雪豹上),您可以使用

arch -i386 python

例如执行它:

robin-mbp:~ $ arch -i386 /usr/bin/python2.6 -c "import sys; print sys.maxint"
2147483647

以32位模式启动解释器。您还可以为系统 python 设置一个环境变量 (VERSIONER_PYTHON_PREFER_32_BIT)。

如果它是您自己构建的 python,目前存在拱选择的错误,但如果您使用 this 中的 pythonw.c 进行重建票它工作正常。

If you are using the apple system python (on snow leopard) you can execute it with

arch -i386 python

eg:

robin-mbp:~ $ arch -i386 /usr/bin/python2.6 -c "import sys; print sys.maxint"
2147483647

to start the interpreter in 32 bit mode. There is also an environment variable you can set for the system python (VERSIONER_PYTHON_PREFER_32_BIT).

If it is your own built python there is currently a bug with arch selection, but if you rebuild with the pythonw.c from this ticket it works fine.

七禾 2024-08-16 08:06:08

如果您不使用系统 python,您可以继续在 ~/.bash_profile 中添加一行:

export VERSIONER_PYTHON_PREFER_32_BIT=yes

If you are not using the system python, you can go ahead and add a line to your ~/.bash_profile:

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