How do I install curl with ares enabled

后端 未结 3 1422
萌比男神i
萌比男神i 2021-01-12 01:56

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

相关标签:
3条回答
  • 2021-01-12 02:20

    You need to install ares separately. You can download it here. Once downloaded, build c-ares (where 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
    

    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):

    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):

    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!

    0 讨论(0)
  • 2021-01-12 02:21

    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 fetched libc-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 of libc-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 a configure script. Look at it's source it 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 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

    0 讨论(0)
  • 2021-01-12 02:34

    If you want installable .deb package instead of putting everything to /usr/local, do this:

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

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

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

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

    Optional: increase version number in the first line of debian/changelog, for example 7.38.0-4+deb8u5 to 7.38.0-4+deb8u6, this way your package will not get overwritten when you install updates to your system.

    Now run command

    dpkg-buildpackage -us -uc -b -j4
    

    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 with c-ares support using this command:

    cd ..
    sudo dpkg -i curl_*.deb libcurl3-*.deb libcurl4-openssl-dev*.deb
    
    0 讨论(0)
提交回复
热议问题