I have curl installed on the latest ubuntu via apt-get and that works fine, however I've been reading about the blocking nature of the DNS lookups and discovered that it's slowing down my app.
I've done apt-get install libc-ares2 but I'm not sure how to tell curl to use that library when doing a lookup.
I posted this question to AskUbuntu but was told it was probably better here..
You need to install ares separately. You can download it here. Once downloaded, build c-ares (where current working directory is "c-ares-${VERSION}"):
following this
Now that ares is built, you can build libcurl using ares. I had an issue referencing ares so I had to copy the ares source directly into libcurl. To do this, rename the 'include' directory created by 'make install' from configuring ares to 'ares'. Then, copy this directory to libcurl's root directory. You can now build libcurl with the ares option (where current working directory is libcurl):
Full example:
EDIT (6/30/2015):
Know that if you're cross-compiling libcurl, you need to cross-compile c-ares with the same cross-compiler settings (--host option).
Hope this helps!
If you want installable
.deb
package instead of putting everything to/usr/local
, do this:This will download
curl
sources with Debian/Ubuntu build files and patches.Edit file
debian/control
: add linelibc-ares-dev
toBuild-Depends
Edit file
debian/rules
: remove--enable-threaded-resolver
and add--enable-ares
toCONFIGURE_ARGS
Optional: increase version number in the first line of
debian/changelog
, for example7.38.0-4+deb8u5
to7.38.0-4+deb8u6
, this way your package will not get overwritten when you install updates to your system.Now run command
It will generate several .deb files after an unreasonably long compilation time, go drink coffee or something while it is compiling.
You can install your new
curl
withc-ares
support using this command:I think the AskUbuntu are thinking that this is a programming question and not a configuration question. The binary you fetched by your
apt-get
command was not compiled with libc-ares2 (as an external library or a linked library). When you fetchedlibc-ares2
you got your computer to the point where it might build the version of cURL you want from source, but now the real work has begun.Commonly you would download the source and look for a file called README or INSTALL. It will (hopefully) talk about a step that has a line like
./configure
. From here you can specify compile time options. It's also possible that the make file for cURL can auto-detect the presence oflibc-ares2
and include it in it's build.However taking a look at the latest source release while there is no
INSTALL
file there is aconfigure
script. Look at it's source it has this line:If you run this command from the source folder:
Then you have a shot at getting the curl build you want. There may very likely be a lot of error messages related to other missing libraries or missing make and GCC. That will be harder to resolve in this answer.
Here is a page on cURL's project homepage that talks you through these steps