【问题标题】:Undefined symbol when importing Python Sybase module on OSX 10.6在 OSX 10.6 上导入 Python Sybase 模块时未定义符号
【发布时间】:2013-10-18 23:12:18
【问题描述】:

我正在尝试让 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 是未定义的。该函数位于已安装的 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 库?

【问题讨论】:

    标签: python macos sybase dynamic-linking dylib


    【解决方案1】:

    修复它。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2017-09-23
      • 1970-01-01
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多