Looking to build the latest cURL from the source?
cURL shipped with the OS may not be up-to-date, and if you need the newest version for a particular requirement, then you need to build from the source.
Lately, I was testing HTTP/3 using cURL with the default shipped version on CentOS, but that didn’t work. BTW, there are more you can do with cURL.
[root@lab ~]# curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.44 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet <a href="https://geekflare.com/tftp-servers-for-windows/">tftp</a>
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
[root@lab ~]#
However, the latest cURL version (7.67) supports HTTP/3. So, I had only one option – build from the source. This is just one example; you may have some other requirements.
The following example is for 7.67 (latest as I write) on CentOS 8.x and Ubuntu 20.x. But the procedure remains the same for any other version.
Prerequisite
Let’s get the required dependencies installed.
- Update the system. Though this is optional, I prefer doing so. I always have up-to-date installed packages.
yum update -y
- Installing the required packages
yum install wget gcc openssl-devel -y
- Download the latest cURL source – you can refer to their official download page to know the latest version.
wget https://curl.haxx.se/download/curl-7.67.0.tar.gz
- Extract the downloaded
gz
file
gunzip -c curl-7.67.0.tar.gz | tar xvf -
It would create a new folder on the present working directory
Building cURL on CentOS/RHEL
Once you’ve downloaded and extracted the latest cURL, it’s time to build them.
- Go inside the newly created folder after extraction
cd curl-7.67.0
- Configure with SSL as below
./configure --with-ssl
- You will see output something like below.
configure: Configured to build curl/libcurl:
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: gcc
CFLAGS: -Werror-implicit-function-declaration -O2 -Wno-system-headers -pthread
CPPFLAGS:
LDFLAGS:
LIBS: -lssl -lcrypto -lssl -lcrypto -lz
curl version: 7.67.0
SSL: enabled (OpenSSL)
SSH: no (--with-libssh2)
zlib: enabled
brotli: no (--with-brotli)
GSS-API: no (--with-gssapi)
TLS-SRP: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6: enabled
Unix sockets: enabled
IDN: no (--with-{libidn2,winidn})
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
Code coverage: disabled
SSPI: no (--enable-sspi)
ca cert bundle: /etc/pki/tls/certs/ca-bundle.crt
ca cert path: no
ca fallback: no
LDAP: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS: no (--enable-ldaps)
RTSP: enabled
RTMP: no (--with-librtmp)
Metalink: no (--with-libmetalink)
PSL: no (libpsl not found)
Alt-svc: no (--enable-alt-svc)
HTTP2: disabled (--with-nghttp2)
HTTP3: disabled (--with-ngtcp2, --with-quiche)
ESNI: no (--enable-esni)
Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
Features: SSL IPv6 UnixSockets libz AsynchDNS NTLM NTLM_WB HTTPS-proxy
- Let’s install them
make
make install
It will take a few seconds to complete, and once done; you can verify the version to ensure it has installed successfully.
Building cURL on Ubuntu
I assume you have downloaded the latest version as explained in the prerequisite section.
- Go to the folder where the downloaded cURL is extracted
- Install the dependencies
apt-get install -y binutils-common binutils make
- If you don’t have the above dependencies (binutils) installed then you may get the following error.
configure: error: ar not found in PATH. Cannot continue without ar.
- And, it’s time to build now with the
configure
command.
./configure --with-ssl
- If no error from the above execution, then finally install with the make command.
make
make install
That’s all!
Verification
Use --version
to see the version details.
# curl --version
curl 7.67.0 (x86_64-pc-linux-gnu) libcurl/7.67.0 OpenSSL/1.0.2k-fips zlib/1.2.7
Release-Date: 2019-11-06
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL UnixSockets
#
Conclusion
You see, its easy when you have the steps. I hope this helps you install cURL from the source.