Software-Installation

如何從 git clone 源安裝 libcurl(有 configure.ac 但缺少 ./configure)

  • May 5, 2022

我正在嘗試從原始碼安裝 libcurl,但它缺少configure執行檔,所以我無法執行./configure. 我如何生成它?

這是我的嘗試:

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

./configure
make 
sudo make install

我被困住了,./configure因為 repo 沒有這個文件。

我的參考資料:

  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

如何curl使用從頭開始建構cmake,包括建構 libcurl,然後如何使用它來建構和執行 C 範例

@Stephen.Harris的答案有效。

這是我的最終版本,基於該答案:

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變數以包含 .so 的路徑curl/build/lib,以便您的載入器在您執行需要它的執行檔時自動載入動態 .so 共享庫。請參閱:https ://stackoverflow.com/a/37558191/4561887和https://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庫安裝和設置

curl設計為使用cmake(cmake3,而不是 cmake2)進行配置。

所以

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

結果文件是./src/curl

引用自:https://unix.stackexchange.com/questions/701456