问题描述
我有curl安装在最新的ubuntu通过apt-get和工作正常,但我一直在阅读关于DNS查找的阻塞性质,发现它减慢了我的应用程序。
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.
我已经做了apt-get安装libc-ares2,但我不知道如何告诉curl在查找时使用该库。
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.
我将此问题发布到AskUbuntu,但被告知这可能更好。
I posted this question to AskUbuntu but was told it was probably better here..
推荐答案
我认为AskUbuntu正在思考这是一个编程问题,而不是配置问题。您的 apt-get
命令获取的二进制文件不是使用libc-ares2(作为外部库或链接库)编译的。当你提取 libc-ares2
时,你的计算机已经可以构建你想要的版本cURL ,但现在的工作已经开始了。
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.
通常你会下载源码,一个名为README或INSTALL的文件。它将(希望)谈论一个有 ./ configure
行的步骤。从这里可以指定编译时选项。也可能是cURL的make文件可以自动检测 libc-ares2
的存在,并将其包含在它的构建中。
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.
但是,在没有 INSTALL
文件的情况下查看最新的源代码版本,还有一个 configure
脚本。看看它的来源它有这行:
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
然后你可以得到你想要的curl build。可能有很多错误消息与其他缺失库或缺少make和GCC相关。
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.
在cURL的项目主页,告诉你通过这些步骤
Here is a page on cURL's project homepage that talks you through these steps
这篇关于如何安装curl with ares启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!