Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C的curl中启用scp?_C_Linux_Curl_Libcurl_Scp - Fatal编程技术网

如何在C的curl中启用scp?

如何在C的curl中启用scp?,c,linux,curl,libcurl,scp,C,Linux,Curl,Libcurl,Scp,我正在使用以下配置构建curl: ./configure --with-ssl --with-libssh2 --prefix=/home/yuvi/development/curlssh 配置后,我可以看到SCP已启用 curl version: 7.24.0 Host setup: x86_64-unknown-linux-gnu Install prefix: /home/yuvi/development/curlssh Compiler:

我正在使用以下配置构建curl:

./configure  --with-ssl --with-libssh2 --prefix=/home/yuvi/development/curlssh
配置后,我可以看到SCP已启用

  curl version:    7.24.0
  Host setup:      x86_64-unknown-linux-gnu
  Install prefix:  /home/yuvi/development/curlssh
  Compiler:        gcc
  SSL support:     enabled (OpenSSL)
  SSH support:     enabled (libSSH2)
  zlib support:    enabled
  krb4 support:    no      (--with-krb4*)
  GSSAPI support:  no      (--with-gssapi)
  SPNEGO support:  no      (--with-spnego)
  TLS-SRP support: no      (--enable-tls-srp)
  resolver:        default (--enable-ares / --enable-threaded-resolver)
  ipv6 support:    enabled
  IDN support:     no      (--with-libidn)
  Build libcurl:   Shared=yes, Static=yes
  Built-in manual: enabled
  Verbose errors:  enabled (--disable-verbose)
  SSPI support:    no      (--enable-sspi)
  ca cert bundle:  /etc/ssl/certs/ca-certificates.crt
  ca cert path:    no
  LDAP support:    no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS support:   no      (--enable-ldaps)
  RTSP support:    enabled
  RTMP support:    no      (--with-librtmp)
  Protocols:       DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SCP SFTP SMTP SMTPS TELNET TFTP
但当我运行示例程序时,我得到以下错误:

* Protocol scp not supported or disabled in libcurl
* Unsupported protocol
我的网址是:

curl_easy_setopt(curl, CURLOPT_URL,"scp://192.168.10.1/mnt/dev.zip");
我能够通过SCP使用命令提示符检索文件,这意味着远程服务器支持SCP。那我哪里做错了

谢谢,
Yuvi

我会尝试LD_PRELOAD以确保程序使用正确的libcurl.so。比如:

LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ldd ./sample-program
LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ./sample-program
在与静态库libcurl.a链接的情况下,该程序包含多个以scp作为子字符串的符号:

$ nm sample-program | grep scp
08092be0 R Curl_handler_scp
         U libssh2_scp_recv
         U libssh2_scp_send64
080789e0 t scp_disconnect
08078bd0 t scp_doing
08078b00 t scp_done
08074a80 t scp_recv
080749f0 t scp_send
这假设curl是在启用调试的-g下编译的,并且调试符号没有从示例程序中剥离。如果nm样本程序| grep scp的输出为空,则:

该程序使用libcurl.a,它是在不支持SCP协议的情况下编译的,或者 程序使用动态库libcurl.so而不是静态库libcurl.a
我会尝试LD_PRELOAD以确保程序使用正确的libcurl.so。比如:

LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ldd ./sample-program
LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ./sample-program
在与静态库libcurl.a链接的情况下,该程序包含多个以scp作为子字符串的符号:

$ nm sample-program | grep scp
08092be0 R Curl_handler_scp
         U libssh2_scp_recv
         U libssh2_scp_send64
080789e0 t scp_disconnect
08078bd0 t scp_doing
08078b00 t scp_done
08074a80 t scp_recv
080749f0 t scp_send
这假设curl是在启用调试的-g下编译的,并且调试符号没有从示例程序中剥离。如果nm样本程序| grep scp的输出为空,则:

该程序使用libcurl.a,它是在不支持SCP协议的情况下编译的,或者 程序使用动态库libcurl.so而不是静态库libcurl.a
您是否进行了安装或以其他方式确保您正在运行刚刚编译的libcurl?能否提供strace日志?您是指curl编写的日志?它已经存在了,我没有得到任何其他信息。您是否进行了安装,或者以其他方式确保您正在运行刚刚编译的libcurl?您能提供strace日志吗?您是指curl编写的日志吗?它已经存在了,我没有得到任何其他东西。我不认为我引用了任何错误的库,因为我从头开始尝试了另一台机器。。似乎我遗漏了一些东西..好的,但是在我的回答中建议的以LD_PRELOAD为前缀的机器上运行的实际输出是什么呢?我使用的是静态库,-lcurl-L/path_to_lib谢谢。。它使用的是/usr/lib/libcurl中的机器默认libcurl,我不认为我引用了任何错误的lib,因为我从头开始尝试使用另一台机器。。似乎我遗漏了一些东西..好的,但是在我的回答中建议的以LD_PRELOAD为前缀的机器上运行的实际输出是什么呢?我使用的是静态库,-lcurl-L/path_to_lib谢谢。。它使用的是机器默认的libcurl,位于/usr/lib/libcurl中