(QNAP NAS)Linux - 安装pycurl(未找到libcurl.a)

时间:2012-10-09 13:25:05

标签: linux libcurl pycurl

我正在尝试在我的NAS上安装Pycurl(QNAP TS-459),我收到错误“libcurl.a:没有这样的文件或目录”。 以下是来自控制台的日志:

[admin@MYSERVER pycurl-7.19.0]# uname -mrs
Linux 2.6.33.2 i686

ipkg status | grep curl
Depends: zlib, openssl, libcurl, diffutils, rcs, expat
Package: libcurl
Package: libcurl-dev
Depends: libcurl
Package: py26-curl
Depends: python26, libcurl (>=7.19.0), openssl
Depends: libcurl, libxml2, openssl, zlib

python setup.py install
ldd /usr/lib/libcurl.soobjdump -Tlddobjdump -T/usr/lib/libcurl.sosodumpls /usr/lib/libcurl.soequery belongscho LD_LIBRARY_PATH$LD_LIBRARY_PATH$ls -la /usr/local/lib/libcurl*echo $LIBCURL_IPK_DIRwhich libcurllocatepython setup.py install
Using curl-config (libcurl 7.24.0)
running install
running build
running build_py
running build_ext
building 'pycurl' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/opt/include -I/share/MD0_DATA/.qpkg/Python/include/python2.7 -c src/pycurl.c -o build/temp.linux-i686-2.7/src/pycurl.o
gcc -pthread -shared build/temp.linux-i686-2.7/src/pycurl.o -L/opt/lib -L/home/slug/optware/ts509/staging/opt/lib -L/home/slug/optware/ts509/staging/lib -L/home/slug/optware/ts509/staging/lib -L/home/slug/optware/ts509/staging/opt/lib -L/home/slug/optware/ts509/staging/lib -L/home/slug/optware/ts509/staging/lib -lcurl -lssl -lssl -lssl -lcrypto -lrt -lz -o build/lib.linux-i686-2.7/pycurl.so -Wl,-rpath,/opt/lib -Wl,-rpath-link,/home/slug/optware/ts509/staging/opt/lib /opt/lib/libcurl.a -Wl,-rpath,/opt/lib -Wl,-rpath-link,/home/slug/optware/ts509/staging/opt/lib
gcc: /opt/lib/libcurl.a: No such file or directory
error: command 'gcc' failed with exit status 1
[admin@MYSERVER pycurl-7.19.0]# ls /opt/lib
lib/     libexec/ 
[admin@MYSERVER pycurl-7.19.0]# ls /opt/lib/libcu*
/opt/lib/libcurl.so        /opt/lib/libcurl.so.4.2.0
/opt/lib/libcurl.so.4
[admin@MYSERVER pycurl-7.19.0]# 

知道如何修复问题吗? 谢谢!

1 个答案:

答案 0 :(得分:2)

今天我在Synology NAS上遇到了同样的问题。 问题是curl-config --libscurl-config --static-libs都会返回一些输出。因此,pycurl尝试为静态和共享库编译。但是libcurl包没有静态库。所以,我用以下方法解决了这个问题:

如果curl-config --static-libs返回curl-config --built-shared,请不要运行yes

这是补丁:

diff --git a/setup.py b/setup.py
index 1c3831b..69bc8b8 100644
--- a/setup.py
+++ b/setup.py
@@ -96,9 +96,13 @@ else:
                 include_dirs.append(e[2:])
         else:
             extra_compile_args.append(e)
-    libs = split_quoted(
-        os.popen("'%s' --libs" % CURL_CONFIG).read()+\
-        os.popen("'%s' --static-libs" % CURL_CONFIG).read())
+    libs = os.popen("'%s' --libs" % CURL_CONFIG).read()
+    is_libcurl_shared = os.popen("'%s' --built-shared" % CURL_CONFIG).read()
+    is_libcurl_shared = string.strip(is_libcurl_shared)
+    if is_libcurl_shared != 'yes':
+        libs = libs + \
+            os.popen("'%s' --static-libs" % CURL_CONFIG).read()
+    libs = split_quoted(libs)
     for e in libs:
         if e[:2] == "-l":
             libraries.append(e[2:])

针对v7.19.0申请。或者从here

获取 setup.py 的最新版本