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

 

参考:

https://www.yuque.com/docs/share/5e859423-0ba7-47bd-b8c6-8a40fe04272e

 

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐