Linux使用Mingw-w64为Windows交叉编译Git

1,前言

http://www.jinbuguo.com/linux/openssl_install.html

2,安装工具

sudo apt update
sudo apt install build-essential mingw-w64

sudo apt-get install build-essential mingw-w64-x86-64-dev make binutils autoconf automake autotools-dev libtool pkg-config curl dpkg-dev autopoint libcppunit-dev libxml2-dev libgcrypt11-dev lzip libgnutls28-dev nettle-dev libgmp-dev libssh2-1-dev libc-ares-dev zlib1g-dev libsqlite3-dev git gcc g++ quilt gcc-mingw-w64-x86-64 wget g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64

3,下载依赖

由于git依赖curl,zlib,openssl,expat,libiconv,所以需要安装开发库或先编译它们。

sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
https://github.com/openssl/openssl/archive/OpenSSL_1_1_1a.zip
http://www.zlib.net/zlib1211.zip

4,编译openssl

5,编译zlib

//它的configure不支持用CC变量来指定交叉工具链
wget http://www.zlib.net/zlib1211.zip
unzip zlib1211.zip
cd zlib-1.2.11
export CC=x86_64-w64-mingw32-gcc
./configure –prefix=/mnt/c/Users/leux/Documents/Debian/dev/zlib –static
make
make install

6,编译openssl

7,编译Git

cd git-1.7.2.2
make –prefix=/mnt/c/Users/leux/Documents/Debian/dev/git all
sudo make prefix=/usr/local instal