1、Ubuntu下MinGW编译环境搭建
本人系统:Ubuntu 14.04 32bit
① apt-get 自动安装
sudo gedit /etc/apt/sources.list
//在sources.list末尾添加,保存
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
sudo apt-get update
sudo apt-get install mingw32
②非常感谢,zeranoe,它做了一个自动下载和编译ffmpeg所需要的mingw及其他工具链的脚本,请到http://ffmpeg.zeranoe.com/blog/下载最新的“MingGW-w64 Build Script 3.6.7”。解压后新建一个目录把它放进去,执行"chmod 777 mingw-w64-build-3.6.7",使这个脚本可以执行。之后运行"./mingw-w64-build-3.6.7",就可以按照提示来做了。如果它提示你缺少依赖库,就按照它的提示先安装依赖库,方式是,执行"sudo apt-get install 库名字",然后配置环境变量,参考④
③ wget下载并手动安装(根据自己的系统选择相应选项安装),本人选择的是32bit
wget http://zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-3.6.0 ./mingw-w64-build-3.6.0
mv mingw-w64-i686 /usr/local/
目录如下:
root@ubuntu:/usr/local/mingw-w64-i686# ls bin i686-w64-mingw32 include lib libexec mingw share
root@ubuntu:/usr/local/mingw-w64-i686/i686-w64-mingw32/bin# ls ar as c++ dlltool g++ gcc ld ld.bfd nm objcopy objdump ranlib strip
A. 修改bash.bashrc
1>gedit /etc/bash.bashrc//在这个文件后添加:
export PATH=$PATH:/usr/local/mingw-w64-i686/i686-w64-mingw32/bin
export PATH=$PATH:/usr/local/mingw-w64-i686/bin
export PATH
2>source/etc/bash.bashrc
B.修改profile
1> gedit /etc/profile//在这个文件后添加
export PATH=$PATH:/usr/local/mingw-w64-i686/i686-w64-mingw32/bin
export PATH=$PATH:/usr/local/mingw-w64-i686/bin
2>source /etc/profile
C. 直接export法
直接执行命令:export PATH=$PATH:/usr/local/mingw-w64-i686/i686-w64-mingw32/bin
export PATH=$PATH:/usr/local/mingw-w64-i686/bin
(注意,如果你关闭了终端,或者新建一个终端,需要重新执行一下这个命令。)
⑤检查是否安装完成:#:i686-w64-mingw32-gcc -v,此时应打印出交叉编译工具的一些信息,则安装成功。
root@ubuntu:/usr/local/mingw-w64-i686/i686-w64-mingw32/bin# i686-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=i686-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/local/mingw-w64-i686/bin/../libexec/gcc/i686-w64-mingw32/4.8.3/lto-wrapper Target: i686-w64-mingw32 Configured with: ../source/gcc-4.8.3/configure --build=i686-pc-linux-gnu --target=i686-w64-mingw32 --disable-shared --enable-static --disable-nls --disable-multilib --prefix=/home/samba_share/mingw-w64-i686 --with-sysroot=/home/samba_share/mingw-w64-i686 --with-mpc=/home/samba_share/pkgs/mpc/mpc-1.0.2-i686 --with-mpfr=/home/samba_share/pkgs/mpfr/mpfr-3.1.2-i686 --with-gmp=/home/samba_share/pkgs/gmp/gmp-6.0.0a-i686 --with-host-libstdcxx='-lstdc++ ' --with-cloog=/home/samba_share/pkgs/cloog/cloog-0.18.0-i686 --with-isl=/home/samba_share/pkgs/isl/isl-0.11.1-i686 --enable-languages=c,c++ --enable-threads=win32 --enable-fully-dynamic-string --enable-lto Thread model: win32 gcc version 4.8.3 (GCC)原文链接:https://www.f2er.com/ubuntu/355120.html