我在Ubuntu(14.04)上使用Python包装器构建lib s2-geometry-library。它一直顺利,直到我在Python中导入lib:
import s2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "s2.py", line 28, in <module>
_s2 = swig_import_helper()
File "s2.py", line 24, in swig_import_helper
_mod = imp.load_module('_s2', fp, pathname, description)
ImportError: libs2.so: cannot open shared object file: No such file or directory
我检查过很多类似的问题,但没有答案可行。 事实上,我确实有libs2.so:
ldd /usr/local/lib/libs2.so
linux-vdso.so.1 => (0x00007ffdfbbfe000)
libs2cellid.so => not found
libs2util.so => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7e7cf6f000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7e7cc6b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7e7c965000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7e7c74e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7e7c385000)
/lib64/ld-linux-x86-64.so.2 (0x000055b5cdcec000)
这里奇怪的是它没有找到libs2cellid.so
和libs2util.so
。事实上,我在同一个文件夹中有三个库:
ls -l /usr/local/lib/
total 1808
-rw-r--r-- 1 root root 98096 Aug 1 12:05 libs2cellid.so
-rw-r--r-- 1 root root 1446781 Aug 1 12:05 libs2.so
-rw-r--r-- 1 root root 284388 Aug 1 12:05 libs2util.so
drwxr-xr-x 2 root root 4096 Aug 1 11:59 pkgconfig
drwxrwsr-x 4 root staff 4096 Nov 23 2016 python2.7
drwxrwsr-x 3 root staff 4096 Jul 29 2016 python3.4
drwxr-xr-x 3 root root 4096 Aug 1 11:56 site_ruby
这是我的lib路径:
$LD_LIBRARY_PATH
/usr/local/lib/libs2util.so:/usr/local/lib/libs2.so:/usr/local/lib/libs2cellid.so:/usr/lib/python2.7/dist-packages/s2/libs2.so:
那么这里有什么问题? 感谢。
答案 0 :(得分:2)
由于您使用的是Ubuntu,因此前缀路径必须为/usr
而不是/usr/local
。您可以在s2-geometry-library/geometry/CMakeCache.txt
中进行更改。设置值如下:CMAKE_INSTALL_PREFIX:PATH=/usr
。您仍然需要重新运行所有安装步骤才能使其正常工作。