Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build git with static linking?

I downloaded git source from https://github.com/git/git as a zip file.

I extracted it into /home/Desktop/denis/git (using Ubuntu).

Now the tutorial here says that I should run

./configure --prefix=/home/denis/git-static CFLAGS="${CFLAGS} -static"

from the above mentioned folder as a step for building git.

But the git source does not appear to have a configure file in it's root folder which I can run (only configure.ac, which I suspect is not what I'm looking for).

What am I missing here? How to build git manually?

I'm doing this because I'm trying to get git working on a shared hosting server where I'm not able to install git.

like image 735
Tool Avatar asked Jul 19 '12 22:07

Tool


1 Answers

The other answers did not work for me. Perhaps they will for others. What did work for me was:

  1. Get the source code
  2. Make a target directory
  3. Enter the source directory
  4. Configure
  5. Build
  6. Install

Use the following commands:

git clone [email protected]:git/git.git
mkdir git-static
cd git
./configure prefix=/path/to/git-static/ CFLAGS="${CFLAGS} -static"
make
make install

This will leave you with a few folders in the git-static directory, but the executable is statically linked. It is also substantially bigger than usual (maybe 1.5 MB bigger).

like image 196
theherk Avatar answered Sep 29 '22 15:09

theherk