1. 程式人生 > >cross-compile-openssl-windows.sh,cross-compile-curl-windows.sh,cross-compile-zlib-windows.sh,build-z

cross-compile-openssl-windows.sh,cross-compile-curl-windows.sh,cross-compile-zlib-windows.sh,build-z

https://gist.github.com/artynet

build zlib with Visual Studio CLI tool
https://gist.github.com/artynet/5a568938dab9f3f5cab96bcfd1438740

:: INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\wdf\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;
:: C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

:: LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;References\CommonConfiguration\Neutral;\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

:: set LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\10\lib\wdf\ucrt\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x86;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86;

set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;
C:\Program Files (x86)\Windows Kits\10\include\wdf\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\shared;
C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

set LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;
C:\Program Files (x86)\Windows Kits\10\lib\wdf\ucrt\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x86;
C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;References\CommonConfiguration\Neutral;\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

:: nmake -n win32\Makefile.msc clean

nmake -n win32\Makefile.msc

Cross compile zLib for mingw32-w64
https://gist.github.com/artynet/75518a8d219abd8c435a9b3b73b4ec3b

#!/bin/bash

# PREFIXDIR=$HOME/Programmi/Zlib-1.2.11-win32-x86

PREFIXDIR=$HOME/Programmi/win32-cross

make -f win32/Makefile.gcc BINARY_PATH=$PREFIXDIR/bin INCLUDE_PATH=$PREFIXDIR/include LIBRARY_PATH=$PREFIXDIR/lib SHARED_MODE=1 PREFIX=i686-w64-mingw32- install

Cross compile OpenSSL for mingw32-w64
https://gist.github.com/artynet/ee042155c93fc110e9422b5d458d9c6b

#!/bin/bash

WORKSPACE=/home/arturo/Programmi/win32-cross

sed -i 's/:.dll.a/ -Wl,--export-all -shared:.dll.a/g' Configure
sed -i 's,.*target already defined.*,$target=$_;,g' Configure

./Configure mingw shared --cross-compile-prefix=i686-w64-mingw32- --prefix=${WORKSPACE}
# ./Configure mingw shared --cross-compile-prefix=x86_64-w64-mingw32- --prefix=${WORKSPACE}

make -j2
make -j2 install

cp *.dll ${WORKSPACE}/lib/
cd ${WORKSPACE}/include

# Fix compile bug in OpenSSL
sed -i '/#define HEADER_X509V3_H/a \\n#ifdef X509_NAME\n#undef X509_NAME\n#endif' openssl/x509v3.h

Cross compile cURL for mingw32-w64
https://gist.github.com/artynet/54c19beafc6ed5b6ff38fe8b8cd1e13b

#!/bin/bash

### Compilare CURL con toolchain mingw-w64 ###

CPPFLAGS="-I/home/arturo/Programmi/win32-cross/include" \
LDFLAGS="-L/home/arturo/Programmi/win32-cross/lib" \
./configure --host=i686-w64-mingw32 \
--with-ssl=/home/arturo/Programmi/win32-cross \
--with-zlib=/home/arturo/Programmi/win32-cross \
--disable-shared --enable-static

# To then make the curl tool linked with everything static, I did this:
make -j3

rm src/curl.exe
make LDFLAGS=-all-static