# Git configure with static curl is failing

4 messages from 2020-04-26 to 2020-04-29. Participants: Paul Smith, brian m. carlson, Jeff King.
Thread: https://gitlist.dev/t/53325

## Paul Smith, 2020-04-26 19:01

Subject: Git configure with static curl is failing
Message-ID: <9d9fe8376e47a9f5330cd644c76d96987fc67c57.camel@mad-scientist.net>
URL: https://gitlist.dev/e/9d9fe8376e47a9f5330cd644c76d96987fc67c57.camel%40mad-scientist.net

```
Hi all;

I'm trying to build Git with my own static curl, not the system curl,
and this isn't working due to an issue in configure.ac's curl locating
code.

I invoke configure with --with-curl=/other/curl where
/other/curl/include/curl and /other/curl/lib/libcurl.a and
/other/curl/bin/curl-config all exist and work correctly.

When configure.ac attempts to local curl, it fails; config.log shows:

  configure:5387: my-gcc -o conftest -O2 \
   -I/other/curl/include -L/other/curl/lib conftest.c -lcurl >&5
  /other/curl/lib/libcurl.a(libcurl_la-content_encoding.o):content_encoding.c:function gzip_init_writer: error: undefined reference to 'zlibVersion'

and many other errors, because the link line is missing needed
libraries.  If curl as a .so this wouldn't matter since libcurl.so
would contain references to the libraries it needs and ld.so would
handle this, but a static library obviously doesn't have that.

The problem appears to be that configure.ac is not using curl-config to
obtain the correct options to link with curl.  If I run
/other/curl/bin/curl-config --lib I get the proper flags:

  $ /other/curl/bin/curl-config --libs
  -L/other/curl/lib -lcurl -lssl -lz -lcrypto -ldl -lpthread

If configure.ac tried to use $CURLDIR/bin/curl-config --libs to obtain
the right linker options, then the link test for curl would work.


```

## brian m. carlson, 2020-04-26 19:47

Subject: Re: Git configure with static curl is failing
Message-ID: <20200426194729.GD6421@camp.crustytoothpaste.net>
URL: https://gitlist.dev/e/20200426194729.GD6421%40camp.crustytoothpaste.net
In-Reply-To: <9d9fe8376e47a9f5330cd644c76d96987fc67c57.camel@mad-scientist.net>

```
On 2020-04-26 at 19:01:54, Paul Smith wrote:
> The problem appears to be that configure.ac is not using curl-config to
> obtain the correct options to link with curl.  If I run
> /other/curl/bin/curl-config --lib I get the proper flags:
> 
>   $ /other/curl/bin/curl-config --libs
>   -L/other/curl/lib -lcurl -lssl -lz -lcrypto -ldl -lpthread
> 
> If configure.ac tried to use $CURLDIR/bin/curl-config --libs to obtain
> the right linker options, then the link test for curl would work.

It doesn't surprise me that configure.ac doesn't use curl-config.  The
configure script is generally not used by the main developers in favor
of just using the makefile itself.

While we should fix that, the makefile does use curl-config, so if you
just use it with any appropriate options without running configure, it
will probably work for you.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

```

## Jeff King, 2020-04-26 23:14

Subject: Re: Git configure with static curl is failing
Message-ID: <20200426231410.GA1702090@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20200426231410.GA1702090%40coredump.intra.peff.net
In-Reply-To: <20200426194729.GD6421@camp.crustytoothpaste.net>

```
On Sun, Apr 26, 2020 at 07:47:29PM +0000, brian m. carlson wrote:

> On 2020-04-26 at 19:01:54, Paul Smith wrote:
> > The problem appears to be that configure.ac is not using curl-config to
> > obtain the correct options to link with curl.  If I run
> > /other/curl/bin/curl-config --lib I get the proper flags:
> > 
> >   $ /other/curl/bin/curl-config --libs
> >   -L/other/curl/lib -lcurl -lssl -lz -lcrypto -ldl -lpthread
> > 
> > If configure.ac tried to use $CURLDIR/bin/curl-config --libs to obtain
> > the right linker options, then the link test for curl would work.
> 
> It doesn't surprise me that configure.ac doesn't use curl-config.  The
> configure script is generally not used by the main developers in favor
> of just using the makefile itself.
> 
> While we should fix that, the makefile does use curl-config, so if you
> just use it with any appropriate options without running configure, it
> will probably work for you.

Usually, yes, though it doesn't use `curl-config --cflags` properly. See
the series at [1]. What's there now, though might be enough for Paul's
case (if it's just a link-time issue).

I do think the autoconf code could do a better job of using curl-config,
along with a few other improvements. I left some thoughts in that
thread.

-Peff

[1] https://lore.kernel.org/git/20200326080540.GA2200522@coredump.intra.peff.net/

```

## Paul Smith, 2020-04-29 01:47

Subject: Re: Git configure with static curl is failing
Message-ID: <16bdb22d9085876f30735a25c1edc2302e008e60.camel@mad-scientist.net>
URL: https://gitlist.dev/e/16bdb22d9085876f30735a25c1edc2302e008e60.camel%40mad-scientist.net
In-Reply-To: <20200426231410.GA1702090@coredump.intra.peff.net>

```
On Sun, 2020-04-26 at 19:14 -0400, Jeff King wrote:
> Usually, yes, though it doesn't use `curl-config --cflags` properly.
> See the series at [1].

Heh.  Some aspects of that thread look familiar :).

Yes, adding 'NO_CURL= CURLDIR=/path/to/curl' to the make line to force
it did fix the problem in my environment.


FWIW, not only is the version of GNU make shipped with MacOS very old
and apparently never to be updated, but it has been reported that there
are bugs in it that don't appear even in the vanilla version of GNU
make 3.81.  There may come a point where continuing to support that
older version won't be worth it...


```
