在OSX 10.6上导入Python的Sybase模块时出现未定义符号10.6

问题描述:

我试图获得python-sybase模块在OSX 10.6上的工作,但我遇到了一些问题。在OSX 10.6上导入Python的Sybase模块时出现未定义符号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库?

修正了它。

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

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