如何从 git clone 源安装 libcurl(有configure.ac,但缺少./configure)

如何从 git clone 源安装 libcurl(有configure.ac,但缺少./configure)

我正在尝试从源代码安装 libcurl,但它缺少configure可执行文件,因此我无法运行./configure.我如何生成它?

这是我的尝试:

time git clone https://github.com/curl/curl.git
cd curl

./configure
make 
sudo make install

我被困住了,./configure因为仓库没有这个文件。

我的参考资料:

  1. https://curl.se/docs/install.html
  2. https://github.com/curl/curl

在 GitHub 存储库中,我看到一些看起来可能有用的文件,但我不知道如何处理它们:

configure.ac
curl-config.in

我也尝试了这个,但它报告了各种错误:

看:https://earthly.dev/blog/autoconf/

aclocal
autoconf
automake --add-missing
time ./configure --with-openssl --with-gnutls

答案1

curl设计为使用cmake(cmake3,而不是 cmake2)进行配置。

所以

git clone https://github.com/curl/curl.git
cd curl
cmake .
make

生成的文件是./src/curl

答案2

如何curl使用从头开始构建cmake,包括构建 libcurl,然后如何使用它来构建和运行 C 示例

答案来自@史蒂芬·哈里斯作品。

这是我的最终版本,基于该答案:

time git clone https://github.com/curl/curl.git

cd curl
mkdir -p build 
cd build
time cmake ..  # takes ~20 sec
time make      # takes ~11 sec

time sudo make install  # takes < 1 sec
cd ../..  # go back up to the same level as where the `curl` dir is

现在更新您的LD_LIBRARY_PATH变量以包含 的路径curl/build/lib,以便每当您运行需要动态 .so 共享库的可执行文件时,加载程序都会自动加载动态 .so 共享库。看:https://stackoverflow.com/a/37558191/4561887https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html

echo "export LD_LIBRARY_PATH=\"$(pwd)/curl/build/lib:\$LD_LIBRARY_PATH\"" >> ~/.bashrc
. ~/.bashrc  # re-source it

现在,共享libcurl.so对象动态库位于/usr/local/lib/libcurl.socurl/build/lib/libcurl.socurl可执行文件位于curl/build/src/curl

您现在可以构建并运行示例,例如,curl/docs/examples/10-at-a-time.c, 像这样:

time ( \
    time g++ -Wall -Wextra -Werror -O3 -std=c++17 \
    curl/docs/examples/10-at-a-time.c \
    -lcurl \
    -o bin/a \
    && time bin/a \
)

但更正一下:我们应该使用 C 来构建示例gcc,而不是使用 C++ 来构建示例g++(即使第一个示例至少也作为 C++ 来构建和运行)。

最终答案:

time ( \
    time gcc -Wall -Wextra -Werror -O3 -std=c17 \
    curl/docs/examples/10-at-a-time.c \
    -lcurl \
    -o bin/a \
    && time bin/a \
)

示例运行和输出:

eRCaGuy_hello_world/cpp$ time ( \
>     time g++ -Wall -Wextra -Werror -O3 -std=c++17 \
>     curl/docs/examples/10-at-a-time.c \
>     -lcurl \
>     -o bin/a \
>     && time bin/a \
> )

real    0m0.139s
user    0m0.085s
sys 0m0.024s
R: 0 - No error <https://www.ibm.com>
R: 0 - No error <https://www.iana.org>
R: 0 - No error <https://www.oracle.com>
R: 0 - No error <https://www.amazon.com>
R: 0 - No error <https://www.google.com>
R: 0 - No error <https://www.ripe.net>
R: 0 - No error <https://www.mysql.com>
R: 0 - No error <https://www.netcraft.com>
R: 0 - No error <https://www.mozilla.org>
R: 0 - No error <https://www.yahoo.com>
R: 0 - No error <https://opensource.org>
R: 0 - No error <https://www.ca.com>
R: 0 - No error <https://www.chip.de>
R: 0 - No error <https://www.hp.com>
R: 0 - No error <https://www.wikipedia.org>
R: 0 - No error <https://www.cnn.com>
R: 0 - No error <https://www.dell.com>
R: 0 - No error <https://www.mit.edu>
R: 0 - No error <https://www.playstation.com>
R: 0 - No error <https://www.apple.com>
R: 0 - No error <https://www.symantec.com>
R: 0 - No error <https://www.uefa.com>
R: 0 - No error <https://www.ebay.com>
R: 0 - No error <https://www.ieee.org>
R: 0 - No error <https://www.fujitsu.com/global/>
R: 0 - No error <https://www.supermicro.com>
R: 0 - No error <https://www.hotmail.com>
R: 0 - No error <https://www.nist.gov>
R: 0 - No error <https://www.cert.org>
R: 0 - No error <https://www.zdnet.com>
R: 0 - No error <https://www.cnet.com>
R: 0 - No error <https://www.ietf.org>
R: 0 - No error <https://news.google.com>
R: 0 - No error <https://www.bbc.co.uk>
R: 0 - No error <https://www.usatoday.com>
R: 0 - No error <https://www.foxnews.com>
R: 0 - No error <https://www.wired.com>
R: 0 - No error <https://www.sky.com>
R: 0 - No error <https://www.cbs.com>
R: 0 - No error <https://slashdot.org>
R: 0 - No error <https://www.msn.com>
R: 0 - No error <https://www.un.org>
R: 0 - No error <https://apache.org>
R: 0 - No error <https://www.nbc.com/>
R: 0 - No error <https://www.informationweek.com>
R: 0 - No error <https://www.heise.de>
R: 0 - No error <https://www.microsoft.com>

real    0m10.476s
user    0m0.892s
sys 0m0.096s

real    0m10.615s
user    0m0.978s
sys 0m0.121s

更进一步:

  1. 您可以在此处的自述文件中查看我所学到的更多详细信息:Ccurl库安装和设置

相关内容