Skip to content

Instantly share code, notes, and snippets.

@mishudark
Last active July 4, 2021 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishudark/3080857 to your computer and use it in GitHub Desktop.
Save mishudark/3080857 to your computer and use it in GitHub Desktop.
compile static git
make configure
./configure --prefix=/var/www/ CFLAGS="${CFLAGS} `pkg-config –static –libs libcurl`"
@bduffany
Copy link

bduffany commented Jul 4, 2021

For anyone stumbling upon this (like I did), this does not actually result in the final binary being static, at least on my system (ubuntu 20.04). You can verify it by running file /var/www/bin/git (assuming your prefix is /var/www like it is in this gist) and it will print "dynamically linked".

Try adding the -static flag to CFLAGS, which tells GCC to only use static libraries, i.e. CFLAGS="${CFLAGS} -static $(pkg-config –static –libs libcurl)". It will result in a lot of errors, likely because Git has a whole bunch of dependencies which do not provide static libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment