# git build failure with libssl (OpenSSL) in custom directory

4 messages from 2010-11-18 to 2010-11-18. Participants: Lars Buitinck, Jonathan Nieder.
Thread: https://gitlist.dev/t/25782

## Lars Buitinck, 2010-11-18 17:37

Subject: git build failure with libssl (OpenSSL) in custom directory
Message-ID: <AANLkTikQC9hncPZkeScWi7OsWw+Optbvxaygyn1p7_sN@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikQC9hncPZkeScWi7OsWw%2BOptbvxaygyn1p7_sN%40mail.gmail.com

```
Hi all,

I've built Git on a Debian Linux box where I don't have root rights. I
first built OpenSSL 1.0.0b and Curl successfully, installing both in
$HOME/apps. I tried to do the same for Git, using

  CPPFLAGS=-I$HOME/apps/include LDFLAGS=-L$HOME/apps/lib make
prefix=$HOME/apps all doc info

but the build failed with the error

      LINK git-fast-import
  /usr/bin/ld: cannot find -lcrypto
  collect2: ld returned 1 exit status
  make: *** [git-fast-import] Error 1

I checked the Makefile, and found

  # CFLAGS and LDFLAGS are for the users to override from the command line.

  CFLAGS = -g -O2 -Wall
  LDFLAGS =

I'm not a Makefile expert, but it seems to me that the last line
contradicts the comment. In any case, changing it to

  LDFLAGS = -L$(HOME)/apps/lib -lssl -lcrypto -ldl

worked, but only after also building and installing a shared library
version of OpenSSL.

I've got a working Git now, but I thought I'd let you know. I haven't
checked out the development version yet.

Regards,
Lars


PS.: I'm not a member of this list, but git-scm.com suggested I send
my question to you.

```

## Jonathan Nieder, 2010-11-18 17:49

Subject: Re: git build failure with libssl (OpenSSL) in custom directory
Message-ID: <20101118174921.GD16610@burratino>
URL: https://gitlist.dev/e/20101118174921.GD16610%40burratino
In-Reply-To: <AANLkTikQC9hncPZkeScWi7OsWw+Optbvxaygyn1p7_sN@mail.gmail.com>

```
Hi Lars,

Lars Buitinck wrote:

>   CPPFLAGS=-I$HOME/apps/include LDFLAGS=-L$HOME/apps/lib make
> prefix=$HOME/apps all doc info

How about

	prefix=$HOME/apps
	make CPPFLAGS=-I$prefix/include LDFLAGS=-L$prefix/lib prefix=$prefix \
		all doc info

?

```

## Lars Buitinck, 2010-11-18 18:04

Subject: Re: git build failure with libssl (OpenSSL) in custom directory
Message-ID: <AANLkTikZBcmbFoCmqT-eorGm3R0YYjkzotc414w_PHyd@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikZBcmbFoCmqT-eorGm3R0YYjkzotc414w_PHyd%40mail.gmail.com
In-Reply-To: <20101118174921.GD16610@burratino>

```
Yes, that works fine with LDFLAGS= in the Makefile. Is this just a
lack of Makefile-fu on my part?

2010/11/18 Jonathan Nieder <jrnieder@gmail.com>:
> Hi Lars,
>
> Lars Buitinck wrote:
>
>>   CPPFLAGS=-I$HOME/apps/include LDFLAGS=-L$HOME/apps/lib make
>> prefix=$HOME/apps all doc info
>
> How about
>
>        prefix=$HOME/apps
>        make CPPFLAGS=-I$prefix/include LDFLAGS=-L$prefix/lib prefix=$prefix \
>                all doc info
>
> ?
>

```

## Jonathan Nieder, 2010-11-18 18:24

Subject: Re: git build failure with libssl (OpenSSL) in custom directory
Message-ID: <20101118182447.GF16610@burratino>
URL: https://gitlist.dev/e/20101118182447.GF16610%40burratino
In-Reply-To: <AANLkTikZBcmbFoCmqT-eorGm3R0YYjkzotc414w_PHyd@mail.gmail.com>

```
Lars Buitinck wrote:

> Yes, that works fine with LDFLAGS= in the Makefile. Is this just a
> lack of Makefile-fu on my part?

In general, "make" likes to get its variable assignments on the
command line rather than from the environment.  This way, Makefile
authors do not have to worry about keeping variable names in a
tightly reined namespace.

On the other hand, it can be convenient to set up the environment
with flags that would be used for multiple builds.  Different
projects deal with that differently:

./configure takes certain values (including LDFLAGS) from the
environment in autotools-using projects.  ./configure --help=short
lists them.

The Linux kernel build system has a separate (namespaced) set of
variables it reads from the environment.  Example: exporting
KBUILD_OUTPUT=$HOME/.cache/linux-2.6 in .profile would save me from
typing "make O=$HOME/.cache/linux-2.6" every time I build the kernel.
They are documented in Documentation/kbuild/kbuild.txt.

Git reads settings from a config.mak file in the toplevel of the
git source tree.  So one can set

	LDFLAGS = -L$(HOME)/opt/git/lib

there and it will be used for all builds.

```
