Why install curl from Source code?
Often times, you may run into issues with curl and virtualbox compatibility, which simply doesn’t allow you to use the latest libcurl.
If you need to install virtualbox, you need to install an older version of libcurl, if you install an older version of libcurl, you cannot use the latest curl.
And the only solution is to install a compatible version of curl that matches your libcurl
version. Let me show you how to install curl from source code on linux, but before that, let’s decide which version to download.
Check curl and libcurl compatibility
Let me show you what went wrong in my case. You can see that my curl and libcurl are incompatible, curl is 7.62.1 & libcurl is 7.52.1. I can do two things to fix this,
- OPTION-1: Install curl 7.52.1 (downgrade the curl)
- OPTION-2: Install libcurl 7.62.1 (upgrade the libcurl)
I will go with option-1 because I need libcurl 7.52.1 for my virtualbox. For some reason, vitualbox is not supporting the latest libcurl, so let me downgrade it.
note: Libcurl 7.52.1 is also called libcurl3
curl --version curl 7.62.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4 libpsl/0.20.2 (+libidn2/2.0.4) libssh2/1.8.0 nghttp2/1.32.0 librtmp/2.3
curl vs libcurl
curl: is a command line tool that existed since 1998 which allows you to transfer files to and from servers on the internet using any many protocols which curl supports.
libcurl: is a library for curl, click here for more info.
Step-1: Download the curl
Visit the link and download the curl 7.52.1
wget https://curl.haxx.se/download/?C=M;O=D
extract the tar file & move it to /opt
tar -xvf curl-7.52.1.tar.bz2 cd curl-7.52.1
Step-2: Build from source code
Make sure you are the sudo user & have all the access.
pkgconfig path for my openssl is located at /usr/lib/pkgconfig
this is typically same for all the openssl setups which are installed using apt-get. --with-ssl
gives curl the ability to handle https requests.
Otherwise you will end up with below error message while requesting https
based endpoints,
Protocol https not supported or disabled in libcurl
env PKG_CONFIG_PATH=/usr/lib/pkgconfig ./configure --with-ssl
Step-3: Installation
make make install
That’s it, the curl is installed with libcurl3 compatible version. Please let me know if this helped you or if you have any issues, in the comments section below.