Linux is not just an operating system that only users comfortable with command-line interfaces could use. Now Modern Linux distros are easy to use, even for beginners, and enables users to debug errors easier.
We will be looking at the “fatal error: curl/curl.h: no such file or directory” issue, causes and how to fix the problem.
What causes the fatal error: curl/curl.h: no such file or directory error?
This error is mainly caused by a Curl installation that is missing or a dependency that makes your script terminate as soon as you import any related libraries. To resolve this, you need to figure out which variant of Curl you need to install according to your specific case.
How do I fix the “fatal error: curl/curl.h: no such file or directory”
To solve the “ fatal error: curl/curl.h: no such file or directory” you must install the required Curl version or corresponding dependencies to resolve the error.
Installing Curl itself is easy, you can do it by following these steps:
Open up a terminal and type in the following command:
sudo apt update
Wait for the command to run,then install Curl using the following command.
sudo apt install curl
Wait and allow the command to execute successfully. When it is done you should have curl installed on your Linux machine successfully.
Verify the installation by typing curl in the terminal monitor the output which should look like this
curl: try 'curl --help' or 'curl --manual'
If this does not solve the issue. Then know that you are missing some dependencies required by your project. One of them being the commonly overlooked dependencies libcurl.
install it using either of these commands below
sudo apt-get install libcurl4-gnutls-dev
Alternatively;
sudo apt-get install libcurl4-nss-dev
Alternatively;
sudo apt-get install libcurl4-openssl-dev
These commands will help you install the GNUtls, NSS and OpenSSL variants of libcurl. Depending on what your project requires, installing one or more of these variants to your system will fix the problem.
And when packaging for a specific operating system or use case, you have to add several specific requirements as well.
Another solution is to add the necessary headers to the program you are using.
If you are developing some native C application using the curl API ( https://curl.haxx.se/libcurl/c/ ) , then include the necessary header at the top of the C program as:
<curl/curl.h>
If the error persists, use the command as a solution to install missing development headers dependency.
$ sudo apt-get install libcurl4-nss-dev
Voila! We have a solution for the “fatal error: curl/curl.h: no such file or directory” error. Try out these few fixes and see if it fixes the problem.