How to install curl with ares enabled

I have curl installed on the latest ubuntu via apt-get, and this works fine, however I read about the blocking nature of DNS queries and found that it slows down my application.

I did apt-get install libc-ares2, but I'm not sure how to tell curl to use this library when doing a search.

I sent this question to AskUbuntu, but I was told that it is probably better here.

+4
source share
3 answers

I think AskUbuntu thinks this is a programming issue, not a configuration issue. The binary you received with the apt-get command was not compiled with libc-ares2 (as an external library or a linked library). When you downloaded libc-ares2 , you got your computer to such an extent that it could create the version of cURL that you want from the source , but now the real work has begun.

You usually download the source and look for the README or INSTALL file. He (hopefully) talks about a step that has a line like ./configure . From here you can specify compile time options. It is also possible that the make file for cURL can automatically detect the presence of libc-ares2 and include it in the assembly.

However, looking at the latest version of the source code, while there is no INSTALL file, there is a configure script. Look at the source that has this line:

 --enable-ares[=PATH] Enable c-ares for DNS lookups 

If you run this command from the source folder:

 ./configure --enable-ares && make && sudo make install 

Then you have a chance to get the right line. There may probably be many error messages related to other missing libraries or missing make and GCC. It will be harder to solve in this answer.

Here is the page on the cURL project home page that tells you about these steps.

+5
source

If you want to install the .deb package instead of putting everything in /usr/local , do the following:

 sudo apt-get build-dep curl sudo apt-get install libc-ares-dev build-essential apt-get source curl cd curl-* 

This will load curl sources with build files and Debian / Ubuntu patches.

Edit debian/control file: add libc-ares-dev to Build-Depends

Edit debian/rules file: remove --enable-threaded-resolver and add --enable-ares to CONFIGURE_ARGS

Optional: increase the version number in the first line of debian/changelog , for example 7.38.0-4+deb8u5 to 7.38.0-4+deb8u6 , so your package will not be overwritten when installing updates on your system.

Now run the command

 dpkg-buildpackage -us -uc -b -j4 

It will generate several .deb files after an unreasonably long compilation time, go for a coffee or something during compilation.

You can install the new curl using c-ares with this command:

 cd .. sudo dpkg -i curl_*.deb libcurl3_*.deb libcurl4-openssl-dev*.deb 
+2
source

You need to install ares separately. You can download here . After loading, create c-ares (where the current working directory is "c-ares - $ {VERSION}"):

 cd /path/to/c-ares-${VERSION} ./configure --prefix=/destination/path/for/ares/install (NOTE: if you specify a destination directory, it must exist already! If you don't specify a prefix, content should be install at location /usr/local/include/) make make install 

after that

Now that ares is built, you can create libcurl using ares. I had a problem with links to ares, so I had to copy the source of ares directly to libcurl. To do this, rename the 'include' directory created by 'make install' from the configuration of ares to 'ares'. Then copy this directory to the libcurl root directory. Now you can create libcurl with the ares option (where is the current libcurl working directory):

 cd /path/to/libcurl ./configure --enable-ares 

Full example:

 cd /User/${USER}/c-ares-1.10.0 mkdir installation make clean ./configure --prefix=/User/${USER}/c-ares-1.10.0/installation make make install mv installation/include installation/ares cp installation/ares /User/${USER}/libcurl/ cd /User/${USER}/libcurl/ ./configure --enable-ares make make install 

EDIT (6/30/2015):

Be aware that if you are compiling cross-compiling libcurl, you need to cross-compile c-ares with the same cross-compiler settings (-host option).

Hope this helps!

0
source

All Articles