compile script for mingw64

本文详细介绍了如何从源码构建Mingw-w64交叉编译环境的过程,包括下载必要的源码包如binutils、gcc及mingw-w64等,并配置环境使其能够为Windows平台生成可执行文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#! /bin/sh

#cd /d/opensource
#wget mingw-w64
#wget gcc
#wget binutils

#make -p /d/opensource
#cd /d/opensource/
#cvs -z9 -d:pserver:anoncvs@sourceware.org:/cvs/src co binutils
#svn co svn://gcc.gnu.org/svn/gcc/trunk gcc-trunk
#svn co https://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/trunk mingw-w64-trunk

mkdir /d/portable/sysroot
mkdir -p /d/build/binutils-build
mkdir -p /d/build/mingw-w64-headers-build
mkdir -p /d/build/mingw-w64-crt-build
mkdir -p /d/build/gcc-build

cd /d/build/binutils-build
../../opensource/binutils-src/configure    \
    --target=x86_64-w64-mingw32 \
    --enable-targets=x86_64-w64-mingw32,i686-w64-mingw32 \
    --with-sysroot=/d/portable/sysroot --prefix=/d/portable/sysroot
make
make install
export PATH="$PATH:/d/portable/sysroot/bin"

cd ../mingw-w64-headers-build
../../opensource/mingw-w64-trunk/mingw-w64-headers/configure \
    --build=i686-pc-mingw32 --host=x86_64-w64-mingw32 \
    --prefix=/d/portable/sysroot
make install
#copy include
cp -a /d/portable/sysroot/include             /d/portable/sysroot/x86_64-w64-mingw32
mkdir -p /d/portable/sysroot/x86_64-w64-mingw32/lib
cp -a /d/portable/sysroot/x86_64-w64-mingw32/lib    /d/portable/sysroot/x86_64-w64-mingw32/lib64
cp -a /d/portable/sysroot/x86_64-w64-mingw32        /d/portable/sysroot/mingw

cd ../gcc-build
../../opensource/gcc-4.7.2-src/configure \
    --target=x86_64-w64-mingw32 --enable-targets=all \
    --with-sysroot=/d/portable/sysroot --prefix=/d/portable/sysroot
make all-gcc
make install-gcc

cd ../mingw-w64-crt-build
../../opensource/mingw-w64-trunk/mingw-w64-crt/configure \
    --host=x86_64-w64-mingw32 --enable-lib32 \
    --with-sysroot=/d/portable/sysroot --prefix=/d/portable/sysroot
make
make install

cp -a /d/portable/sysroot/lib                /d/portable/sysroot/x86_64-w64-mingw32
cp -a /d/portable/sysroot/lib32                /d/portable/sysroot/x86_64-w64-mingw32
cp -a /d/portable/sysroot/x86_64-w64-mingw32/lib/*    /d/portable/sysroot/x86_64-w64-mingw32/lib64
cp -a /d/portable/sysroot/x86_64-w64-mingw32/*        /d/portable/sysroot/mingw

cd ../gcc-build
make
make install
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值