libcurl linux 静态链接库_Ubuntu12.04 链接libcurl静态库

> wget http://curl.haxx.se/download/curl-7.29.0.tar.gz

> tar zxvf curl-7.29.0.tar.gz

> cd curl-7.29.0

> ./configure --prefix=/usr/local/curl --disable-shared --enable-static --without-libidn --without-ssl --without-librtmp --without-gnutls --without-nss --without-libssh2 --without-zlib --without-winidn --disable-rtsp --disable-ldap --disable-ldaps --disable-ipv6

> make

> sudo make install

> vi a.c

#include

int main() {

printf("%s\n", curl_version());

return 0;

}

> curl-config --static-libs

/usr/local/curl/lib/libcurl.a -lrt

> gcc a.c -static $(/usr/local/curl/bin/curl-config --static-libs --cflags)

> file a.out

a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=0x251f05855bb8e2e633171019d5e6c4bcc3d80a80, not stripped

> ./a.out

libcurl/7.29.0

注意我这里不需要其它功能不需要ssl等,这里全disable掉,不然会在连接时报错:

如:url.c|| undefined reference to ‘idn_free’

我就在这里郁闷了半天。

如果你没有disable掉,但你的机器上又没有安装相应的库,link时也会报错。

./configure --prefix=/usr/local/curl --disable-shared --enable-static --without-libidn --without-ssl --without-librtmp --without-gnutls --without-nss --without-libssh2 --without-zlib --without-winidn --disable-rtsp --disable-ldap --disable-ldaps --disable-ipv6

curl version:     7.29.0

Host setup:       i686-pc-linux-gnu

Install prefix:   /usr/local/curl

Compiler:         gcc

SSL support:      no      (--with-{ssl,gnutls,nss,polarssl,cyassl,axtls,winssl,darwinssl} )

SSH support:      no      (--with-libssh2)

zlib support:     no      (--with-zlib)

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:     no      (--enable-ipv6)

IDN support:      no      (--with-{libidn,winidn})

Build libcurl:    Shared=no, Static=yes

Built-in manual:  enabled

--libcurl option: enabled (--disable-libcurl-option)

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:     no      (--enable-rtsp)

RTMP support:     no      (--with-librtmp)

metalink support: no      (--with-libmetalink)

Protocols:        DICT FILE FTP GOPHER HTTP IMAP POP3 SMTP TELNET TFTP

KB94248  - How To Use the C Run-Time

http://support.microsoft.com/kb/94248/en-us

KB140584 - How to link with the correct C Run-Time (CRT) library

http://support.microsoft.com/kb/140584/en-us

KB190799 - Potential Errors Passing CRT Objects Across DLL Boundaries

http://msdn.microsoft.com/en-us/library/ms235460

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值