0

I'm trying to install libcurl from source, but it's missing the configure executable, so I can't run ./configure. How do I generate it?

Here is my attempt:

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

./configure
make 
sudo make install

I'm stuck at ./configure because the repo doesn't have this file.

My references:

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

In the GitHub repo, I see a few files that look potentially useful, but I don't know what to do with them:

configure.ac
curl-config.in

I tried this too, but it reported various errors:

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

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

2 Answers 2

2

curl is designed to be configured with cmake (cmake3, not cmake2).

So

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

The resulting file is ./src/curl

1
0

How to build curl from scratch using cmake, including building libcurl, and then how to use it to build and run the C examples

The answer from @Stephen.Harris works.

Here is my final version, based off of that answer:

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

Now update your LD_LIBRARY_PATH variable to contain the path to curl/build/lib, so that your loader will automatically load the dynamic .so shared library whenever you run an executable requiring it. See: https://stackoverflow.com/a/37558191/4561887 and 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

Now, you have the libcurl.so shared object dynamic library located at /usr/local/lib/libcurl.so and curl/build/lib/libcurl.so, and the curl executable is at curl/build/src/curl.

You can now build and run the examples, for instance, curl/docs/examples/10-at-a-time.c, like this:

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

Correction though: we should build the examples as C with gcc, rather than as C++ with g++ (even though the first one at least does build and run as C++ too).

Final answer:

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

Sample run and output:

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

Going further:

  1. You can see even more details of what I've learned in my readme notes here: C curl library installation & setup

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .