ubuntu 上的 curl 安装 针对 sftp

一.直接尝试curl的sftp安装

参考:http://curl.haxx.se/docs/install.html

    ./configure  --prefix="/usr/local/curl" --with-libssh2 --with-ssl LIBS=-ldl
    make
    make install
无错误安装完成后,/usr/local/curl/bin/curl是最新的

如果之前安过curl则路径可能不对,which curl一下看看程序的指定运行路径,我的是/usr/local/bin/curl
运行路径不对的话去到/usr/local/bin/curl路径下建立软连接指到/usr/local/curl/bin/curl,ln -s /usr/local/curl/bin/curl curl

测试: curl -T  sftp://:@/path/ 用sftp上传个文件试试
如果是自己写的代码是直接调用libcurl库的,程序生成后 ldd program 看看使用的库是不是
/usr/local/curl/lib下的,不是的话用软连接连接过去

二.第一步中的./configure可能会报找不到libSSH.so库的错误,需要安装libssh2
    sudo apt-get install openssl
    cd /usr/src/
    sudo wget http://libssh2.org/download/libssh2-1.3.0.tar.gz
    sudo tar zxvf libssh2-1.3.0.tar.gz
    cd libssh2-1.3.0/
       ./configure
    sudo make all install
./configure可能会报“configure: error: cannot find OpenSSL or Libgcrypt,。。。”的错误,说明没有连接到ssl
可以用 ./configure CPPFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib" LIBS=-ldl 我的ssl路径是/usr/local/ssl/,有些可能会是 。。。/openssl/lib
找不到ssl库路径的建议从openssl官网 http://www.libssh2.org/download/?C=M;O=D 获取手动安装一下


参考:

http://curl.haxx.se/docs/install.html

http://blog.sina.com.cn/s/blog_4ce89f200100xsuo.html

http://blog.chinaunix.net/uid-20682147-id-3712669.html

http://comments.gmane.org/gmane.network.ssh.libssh2.devel/3849

你可能感兴趣的:(linux相关,C/C++)