最近項目需要重新編譯libcurl 使其支持ssl,在這里進行記錄:
下載openssl : curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.zip
創建安裝目錄:/opt/openssl
配置openssl動態庫:./config --prefix=/opt/openssl --shared # 默認安裝在 /usr/local/lib下; 但是會與先有的openssl 沖突;建議安裝到另外一個文件夾中,方便配合libcurl編譯;
編譯:make -j 30 && make install
編譯libcurl
下載curl 源碼:https://curl.haxx.se/download.html
我使用的版本:https://curl.haxx.se/download/curl-7.71.1.tar.gz
創建裝目錄:/opt/libcurl
編譯:./configure --with-ssl=/opt/openssl # 默認安裝在 /usr/local/lib下; --prefix=/opt/libcurl, 我選擇安裝到默認位置,/usr/local下;
安裝:make -j 30 && make install
配置 LD_LIBRARY_PATH 環境變量,或者庫位置,即可引入到項目中;項目編譯時,我使用libcurl安裝位置的是默認位置,方便配置;openssl 是安裝在 /opt/openssl下;通過上述步驟,簡單解決了環境依賴問題;
Ubuntu 環境安裝libcurl with ssl 支持:
apt install libcurl4-openssl-dev # 用軟件源中直接安裝libcurl4-openssl庫
保持更新,轉載請注明出處;更多內容請關注cnblogs.com/xuyaowen;