一、背景
某个工程中需要使用libcurl访问https网站,为了可移植性,需要将libcurl编译成静态的。由于访问的是https开头的网站,所以还需加入对OpenSSL的编译,同样使用编译。
二、静态编译OpenSSL
1、下载OpenSSL源码:
git clone https://github.com/openssl/openssl.git
git checkout -b OpenSSL_1_0_0-stable origin/OpenSSL_1_0_0-stable //分支自己按需选取
git pull
2、./config --prefix=/path/to/openssl -fPIC no-shared no-dso no-ssl3 //--prefix指定安装路径
3、make depend
4、make
5、make install
三、静态编译libcurl
1、下载源码包:
https://curl.haxx.se/download/curl-7.29.0.tar.gz(按需选择包版本:https://curl.haxx.se/download/),进入源码目录。
2、./configure --prefix=/path/to/curl --disable-shared --enable-static --with-ssl=/path/to/openssl --without-libidn --without-librtmp --without-nss --without-libssh2 --without-zlib --without-winidn --without-gnutls --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-