问题描述:

[root@localhost pycurl-7.19.0]# python setup.py install --curl-config=/usr/bin/curl-config 
Using /usr/bin/curl-config (libcurl 7.15.5) 
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_SSL=1 -I/usr/local/include/python2.7 -c src/pycurl.c -o build/temp.linux-x86_64-2.7/src/pycurl.o 
src/pycurl.c:61:4: error: #error "Need libcurl version 7.19.0 or greater to compile pycurl." 
src/pycurl.c:1134: error: expected declaration specifiers or ‘...’ before ‘curlsocktype’ 
src/pycurl.c:1135: warning: ‘struct curl_sockaddr’ declared inside parameter list 
src/pycurl.c:1135: warning: its scope is only this definition or declaration, which is probably not what you want 
src/pycurl.c: In function ‘opensocket_callback’: 
src/pycurl.c:1148: error: dereferencing pointer to incomplete type 
src/pycurl.c:1148: error: dereferencing pointer to incomplete type 
src/pycurl.c:1148: error: dereferencing pointer to incomplete type 
src/pycurl.c: In function ‘do_curl_setopt’: 
src/pycurl.c:1624: error: ‘CURLOPT_SSH_PUBLIC_KEYFILE’ undeclared (first use in this function) 
src/pycurl.c:1624: error: (Each undeclared identifier is reported only once 
src/pycurl.c:1624: error: for each function it appears in.) 
src/pycurl.c:1625: error: ‘CURLOPT_SSH_PRIVATE_KEYFILE’ undeclared (first use in this function) 
src/pycurl.c:1626: error: ‘CURLOPT_COPYPOSTFIELDS’ undeclared (first use in this function) 
src/pycurl.c:1627: error: ‘CURLOPT_SSH_HOST_PUBLIC_KEY_MD5’ undeclared (first use in this function) 
src/pycurl.c:1629: error: ‘CURLOPT_ISSUERCERT’ undeclared (first use in this function) 
src/pycurl.c:2020: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘opensocket_cb’ 
src/pycurl.c:2020: error: ‘opensocket_cb’ undeclared (first use in this function) 
src/pycurl.c:2071: error: ‘CURLOPT_OPENSOCKETFUNCTION’ undeclared (first use in this function) 
src/pycurl.c:2076: error: ‘CURLOPT_OPENSOCKETDATA’ undeclared (first use in this function) 
src/pycurl.c: In function ‘do_curl_getinfo’: 
src/pycurl.c:2175: error: ‘CURLINFO_REDIRECT_URL’ undeclared (first use in this function) 
src/pycurl.c:2176: error: ‘CURLINFO_PRIMARY_IP’ undeclared (first use in this function) 
src/pycurl.c:2194: error: ‘CURLINFO_APPCONNECT_TIME’ undeclared (first use in this function) 
src/pycurl.c: In function ‘do_multi_setopt’: 
src/pycurl.c:2461: error: ‘CURLMOPT_PIPELINING’ undeclared (first use in this function) 
src/pycurl.c:2464: error: ‘CURLMOPT_MAXCONNECTS’ undeclared (first use in this function) 
src/pycurl.c:2479: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘t_cb’ 
src/pycurl.c:2479: error: ‘t_cb’ undeclared (first use in this function) 
src/pycurl.c:2489: error: ‘CURLMOPT_TIMERFUNCTION’ undeclared (first use in this function) 
src/pycurl.c:2491: error: ‘CURLMOPT_TIMERDATA’ undeclared (first use in this function) 
src/pycurl.c: In function ‘do_multi_socket_action’: 
src/pycurl.c:2576: warning: implicit declaration of function ‘curl_multi_socket_action’ 
src/pycurl.c: In function ‘initpycurl’: 
src/pycurl.c:3555: error: ‘CURLE_SSL_CACERT_BADFILE’ undeclared (first use in this function) 
src/pycurl.c:3556: error: ‘CURLE_REMOTE_FILE_NOT_FOUND’ undeclared (first use in this function) 
src/pycurl.c:3557: error: ‘CURLE_SSH’ undeclared (first use in this function) 
src/pycurl.c:3558: error: ‘CURLE_SSL_SHUTDOWN_FAILED’ undeclared (first use in this function) 
src/pycurl.c:3707: error: ‘CURLOPT_OPENSOCKETFUNCTION’ undeclared (first use in this function) 
src/pycurl.c:3719: error: ‘CURLOPT_SSL_SESSIONID_CACHE’ undeclared (first use in this function) 
src/pycurl.c:3720: error: ‘CURLOPT_SSH_AUTH_TYPES’ undeclared (first use in this function) 
src/pycurl.c:3721: error: ‘CURLOPT_SSH_PUBLIC_KEYFILE’ undeclared (first use in this function) 
src/pycurl.c:3722: error: ‘CURLOPT_SSH_PRIVATE_KEYFILE’ undeclared (first use in this function) 
src/pycurl.c:3723: error: ‘CURLOPT_FTP_SSL_CCC’ undeclared (first use in this function) 
src/pycurl.c:3724: error: ‘CURLOPT_TIMEOUT_MS’ undeclared (first use in this function) 
src/pycurl.c:3725: error: ‘CURLOPT_CONNECTTIMEOUT_MS’ undeclared (first use in this function) 
src/pycurl.c:3726: error: ‘CURLOPT_HTTP_TRANSFER_DECODING’ undeclared (first use in this function) 
src/pycurl.c:3727: error: ‘CURLOPT_HTTP_CONTENT_DECODING’ undeclared (first use in this function) 
src/pycurl.c:3728: error: ‘CURLOPT_NEW_FILE_PERMS’ undeclared (first use in this function) 
src/pycurl.c:3729: error: ‘CURLOPT_NEW_DIRECTORY_PERMS’ undeclared (first use in this function) 
src/pycurl.c:3730: error: ‘CURLOPT_POST301’ undeclared (first use in this function) 
src/pycurl.c:3731: error: ‘CURLOPT_PROXY_TRANSFER_MODE’ undeclared (first use in this function) 
src/pycurl.c:3732: error: ‘CURLOPT_COPYPOSTFIELDS’ undeclared (first use in this function) 
src/pycurl.c:3733: error: ‘CURLOPT_SSH_HOST_PUBLIC_KEY_MD5’ undeclared (first use in this function) 
src/pycurl.c:3736: error: ‘CURLOPT_ISSUERCERT’ undeclared (first use in this function) 
src/pycurl.c:3737: error: ‘CURLOPT_ADDRESS_SCOPE’ undeclared (first use in this function) 
src/pycurl.c:3739: error: ‘CURLMOPT_TIMERFUNCTION’ undeclared (first use in this function) 
src/pycurl.c:3741: error: ‘CURLMOPT_PIPELINING’ undeclared (first use in this function) 
src/pycurl.c:3742: error: ‘CURLMOPT_MAXCONNECTS’ undeclared (first use in this function) 
src/pycurl.c:3773: error: ‘CURLSSH_AUTH_ANY’ undeclared (first use in this function) 
src/pycurl.c:3774: error: ‘CURLSSH_AUTH_NONE’ undeclared (first use in this function) 
src/pycurl.c:3775: error: ‘CURLSSH_AUTH_PUBLICKEY’ undeclared (first use in this function) 
src/pycurl.c:3776: error: ‘CURLSSH_AUTH_PASSWORD’ undeclared (first use in this function) 
src/pycurl.c:3777: error: ‘CURLSSH_AUTH_HOST’ undeclared (first use in this function) 
src/pycurl.c:3778: error: ‘CURLSSH_AUTH_KEYBOARD’ undeclared (first use in this function) 
src/pycurl.c:3779: error: ‘CURLSSH_AUTH_DEFAULT’ undeclared (first use in this function) 
src/pycurl.c:3788: error: ‘CURLINFO_APPCONNECT_TIME’ undeclared (first use in this function) 
src/pycurl.c:3804: error: ‘CURLINFO_REDIRECT_URL’ undeclared (first use in this function) 
src/pycurl.c:3805: error: ‘CURLINFO_PRIMARY_IP’ undeclared (first use in this function) 
src/pycurl.c:3825: error: ‘CURL_CSELECT_IN’ undeclared (first use in this function) 
src/pycurl.c:3826: error: ‘CURL_CSELECT_OUT’ undeclared (first use in this function) 
src/pycurl.c:3827: error: ‘CURL_CSELECT_ERR’ undeclared (first use in this function) 
error: command 'gcc' failed with exit status 1

 

问题解决:

其中有一句 
src/pycurl.c:61:4: error: #error "Need libcurl version 7.19.0 or greater to compile pycurl."

提示说libcurl 版本太低... 
root@localhost pycurl-7.19.0]# curl --version 
curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 
Protocols: tftp ftp telnet dict ldap http file https ftps 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz 
果然7.15.5小于 7.19 
wget http://curl.haxx.se/download/curl-7.21.4.tar.gz 
.configure &&make && make install

 

下面继续问题 
[root@localhost pycurl-7.19.0]# python 
Python 2.4.3 (#1, Sep 3 2009, 15:37:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import pycurl 
Traceback (most recent call last): 
File "<stdin>", line 1, in ?
ImportError: libcurl.so.4: cannot open shared object file: No such file or directory 
>>>

这问题因为机器是64的.所以找不到. 
解决方法:

[root@localhost pycurl-7.19.0]# find /usr -name "libcurl.so*" 
/usr/local/src/curl-7.21.4/lib/.libs/libcurl.so 
/usr/local/src/curl-7.21.4/lib/.libs/libcurl.so.4 
/usr/local/src/curl-7.21.4/lib/.libs/libcurl.so.4.2.0 
/usr/local/lib/libcurl.so 
/usr/local/lib/libcurl.so.4 
/usr/local/lib/libcurl.so.4.2.0 
/usr/lib/libcurl.so.3.0.0 
/usr/lib/libcurl.so.3 
/usr/lib/libcurl.so 
/usr/lib64/libcurl.so.3.0.0 
/usr/lib64/libcurl.so.3 
/usr/lib64/libcurl.so 
[root@localhost pycurl-7.19.0]# ln -s /usr/local/lib/libcurl.so.4.2.0 /usr/lib64/libcurl.so.4 
[root@localhost pycurl-7.19.0]# python 
Python 2.4.3 (#1, Sep 3 2009, 15:37:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import pycurl 
>>> 
[root@localhost pycurl-7.19.0]# ls /usr/local/lib/libcurl.so.4 -l 
lrwxrwxrwx 1 root root 16 Apr 11 22:50 /usr/local/lib/libcurl.so.4 -> libcurl.so.4.2.0