我有一个包含 Python 版本 2.6.5 和 2.7.1 的系统,我注意到一个 LoadLibrary 工作,另一个没有。
Python 2.7.1 (r271:86832, Nov 30 2010, 10:03:07)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("./mylib.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/local/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: ./mylib.so: undefined symbol: compress2
在工作 2.6.5 土地上:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("./mylib.so")
<CDLL './mylib.so', handle 98bbd88 at b785c94c>
有谁知道一个很好的方法来弄清楚为什么 python 2.7.1 不起作用?