gpt4 book ai didi

python - 在 OSX 10.6 上导入 Python Sybase 模块时出现 undefined symbol

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:42 25 4
gpt4 key购买 nike

我试图让 python-sybase 模块在 OSX 10.6 上运行,但我遇到了一些障碍。

当我这样做

import Sybase

我明白了

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Sybase.py", line 15, in <module>
from sybasect import *
ImportError: dlopen(/Library/Python/2.6/site-packages/python_sybase-0.40pre2-py2.6-macosx-10.6-universal.egg/sybasect.so, 2): Symbol not found: _blk_alloc
Referenced from: /Library/Python/2.6/site-packages/python_sybase-0.40pre2-py2.6-macosx-10.6-universal.egg/sybasect.so
Expected in: flat namespace
in /Library/Python/2.6/site-packages/python_sybase-0.40pre2-py2.6-macosx-10.6-universal.egg/sybasect.so

我看了一下sybasect.so,果然_blk_alloc是undefined。该函数位于安装的Sybase的sybblk.dylib中,其包含目录在LD_LIBRARY_PATH中。

当我使用 python setup.py build 编译 python-sybase 时,gcc 命令似乎正确地找到了所有正确的库,但由于某些原因,这些库在之后似乎没有被链接将 sybasect.so 安装到 Python 模块目录。

gcc命令是

gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -arch x86_64 build/temp.macosx-10.6-universal-2.6/blk.o build/temp.macosx-10.6-universal-2.6/databuf.o build/temp.macosx-10.6-universal-2.6/cmd.o build/temp.macosx-10.6-universal-2.6/conn.o build/temp.macosx-10.6-universal-2.6/ctx.o build/temp.macosx-10.6-universal-2.6/datafmt.o build/temp.macosx-10.6-universal-2.6/iodesc.o build/temp.macosx-10.6-universal-2.6/locale.o build/temp.macosx-10.6-universal-2.6/msgs.o build/temp.macosx-10.6-universal-2.6/numeric.o build/temp.macosx-10.6-universal-2.6/money.o build/temp.macosx-10.6-universal-2.6/datetime.o build/temp.macosx-10.6-universal-2.6/date.o build/temp.macosx-10.6-universal-2.6/sybasect.o -L/Applications/Sybase/System/OCS-15_0/lib -lsybblk -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -o build/lib.macosx-10.6-universal-2.6/sybasect.so

-L/Applications/Sybase/System/OCS-15_0/lib 位置正确,并且该文件夹包含所有正确的 .dylib。

当我运行 otool 时,输出是:

$ otool -L build/lib.macosx-10.6-universal-2.6/sybasect.so
build/lib.macosx-10.6-universal-2.6/sybasect.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

我期待在那里看到 Sybase 库。

我对 Mac 上的链接有点陌生。如何确保 sybasect.so 引用 Sybase 库?

最佳答案

已修复。

问题是我链接到的各种 Sybase 库只有 32 位,但我在 64 位模式下运行 Python。修复只是在 32 位模式下运行 python。

我使用命令 defaults write com.apple.versioner.python Prefer-32-Bit -bool yes 因为我对 64 位模式没有任何特殊需求。

关于python - 在 OSX 10.6 上导入 Python Sybase 模块时出现 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19460413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com