[关闭]
@chenyiliang 2018-07-11T06:53:48.000000Z 字数 7387 阅读 4542

WIN10 MSYS2 环境配置

MSYS


1. 安装 MSYS2, MingW-64, DOWNLOAD

i686 和 x86_64 任选一个安装, 在安装目录下会有一个MSYS2.EXE MINGW32.EXE MINGW64.EXE

安装软件使用MSYS2.EXE, 编译gcc时,32位使用MINGW32.EXE,64位使用MINGW64.EXE,安装完目录如下:

image_1br3u1tt01jup82q1euq18nvfde9.png-115.1kB

更新, 只要更新了 pacman 这个命令本身就会出现卡死的情况,这时要使用任务管理器关闭,然后再打开MSYS2再执行一次更新,这时可以正常执行下去

  1. ## 先执行下面的命令更新MYSYS2系统
  2. pacman -Syu

2. 打开MSYS2.EXE,安装gcc 及相关工具

image_1br3uaenh1rie41vtl1igkr9q26.png-169.9kB

  1. ## 安装 gcc llvm clang 及相关库的命令如下:
  2. pacman -Sy mingw32/mingw-w64-i686-gcc mingw32/mingw-w64-i686-gcc-ada mingw32/mingw-w64-i686-gcc-fortran mingw32/mingw-w64-i686-gcc-libgfortran mingw32/mingw-w64-i686-gcc-libs mingw32/mingw-w64-i686-gcc-objc mingw32/mingw-w64-i686-lcov mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-gcc-ada mingw64/mingw-w64-x86_64-gcc-fortran mingw64/mingw-w64-x86_64-gcc-libgfortran mingw64/mingw-w64-x86_64-gcc-libs mingw64/mingw-w64-x86_64-gcc-objc mingw64/mingw-w64-x86_64-lcov msys/gcc msys/gcc-fortran msys/mingw-w64-cross-gcc mingw32/mingw-w64-i686-clang mingw32/mingw-w64-i686-compiler-rt mingw32/mingw-w64-i686-lld mingw32/mingw-w64-i686-llvm mingw32/mingw-w64-i686-polly mingw64/mingw-w64-x86_64-clang mingw64/mingw-w64-x86_64-compiler-rt mingw64/mingw-w64-x86_64-lld mingw64/mingw-w64-x86_64-llvm mingw64/mingw-w64-x86_64-polly msys/clang-svn msys/lld-svn msys/llvm-svn mingw32/mingw-w64-i686-gdb mingw32/mingw-w64-i686-gdbm mingw64/mingw-w64-x86_64-gdb mingw64/mingw-w64-x86_64-gdbm msys/cgdb msys/gdb msys/gdbm msys/libgdbm msys/libgdbm-devel msys/sharutils msys/perl msys/make msys/icmake msys/cmake mingw32/mingw-w64-i686-cmake mingw32/mingw-w64-i686-dmake mingw32/mingw-w64-i686-make mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-dmake mingw64/mingw-w64-x86_64-make automake autogen python2 python3 mingw32/mingw-w64-i686-binutils mingw64/mingw-w64-x86_64-binutils msys/binutils msys/mingw-w64-cross-binutils mingw32/mingw-w64-i686-clang-analyzer mingw32/mingw-w64-i686-clang-tools-extra mingw64/mingw-w64-x86_64-clang-analyzer mingw64/mingw-w64-x86_64-clang-tools-extra mingw32/mingw-w64-i686-yasm mingw64/mingw-w64-x86_64-yasm msys/yasm msys/yasm-devel mingw32/mingw-w64-i686-nasm mingw64/mingw-w64-x86_64-nasm msys/nasm mingw32/mingw-w64-i686-dbus-glib mingw32/mingw-w64-i686-geocode-glib mingw32/mingw-w64-i686-glib-networking mingw32/mingw-w64-i686-glib2 mingw32/mingw-w64-i686-glibmm mingw32/mingw-w64-i686-json-glib mingw32/mingw-w64-i686-jsonrpc-glib mingw32/mingw-w64-i686-libgda mingw32/mingw-w64-i686-libgit2-glib mingw32/mingw-w64-i686-libgusb mingw32/mingw-w64-i686-libical-glib mingw32/mingw-w64-i686-libvirt-glib mingw32/mingw-w64-i686-taglib mingw32/mingw-w64-i686-template-glib mingw64/mingw-w64-x86_64-dbus-glib mingw64/mingw-w64-x86_64-geocode-glib mingw64/mingw-w64-x86_64-glib-networking mingw64/mingw-w64-x86_64-glib2 mingw64/mingw-w64-x86_64-glibmm mingw64/mingw-w64-x86_64-json-glib mingw64/mingw-w64-x86_64-jsonrpc-glib mingw64/mingw-w64-x86_64-libgda mingw64/mingw-w64-x86_64-libgit2-glib mingw64/mingw-w64-x86_64-libgusb mingw64/mingw-w64-x86_64-libical-glib mingw64/mingw-w64-x86_64-libvirt-glib mingw64/mingw-w64-x86_64-taglib mingw64/mingw-w64-x86_64-template-glib msys/glib2-devel msys/glib2-docs p7zip unrar diffutils subversion git emacs zip mingw32/mingw-w64-i686-libzip mingw64/mingw-w64-x86_64-libzip tar mingw32/mingw-w64-i686-nsis mingw64/mingw-w64-x86_64-nsis msys/autoconf msys/bison msys/cloog-devel msys/diffstat msys/dos2unix msys/gperf msys/groff msys/heimdal-devel msys/icu-devel msys/intltool msys/libbz2-devel msys/libcrypt-devel msys/libcurl-devel msys/libdb-devel msys/libgc-devel msys/libgcrypt-devel msys/libgnutls-devel msys/libnpth-devel msys/ncurses-devel msys/openssl-devel msys/patch msys/patchutils msys/swig mingw32/mingw-w64-i686-ctags mingw64/mingw-w64-x86_64-ctags mingw32/mingw-w64-i686-libtool mingw64/mingw-w64-x86_64-libtool msys/libedit msys/libltdl msys/libtool mingw64/mingw-w64-x86_64-mcpp mingw32/mingw-w64-i686-mcpp mingw32/mingw-w64-i686-cppunit mingw64/mingw-w64-x86_64-cppunit mingw32/mingw-w64-i686-cppcheck mingw32/mingw-w64-i686-antlr4-runtime-cpp mingw32/mingw-w64-i686-cpptest mingw64/mingw-w64-x86_64-cppcheck mingw64/mingw-w64-x86_64-antlr4-runtime-cpp mingw64/mingw-w64-x86_64-cpptest msys/bisonc++ mingw32/mingw-w64-i686-flexdll mingw64/mingw-w64-x86_64-flexdll
  1. pacman -Syu mingw32/mingw-w64-i686-gcc mingw32/mingw-w64-i686-gcc-ada mingw32/mingw-w64-i686-gcc-fortran mingw32/mingw-w64-i686-gcc-libgfortran mingw32/mingw-w64-i686-gcc-libs mingw32/mingw-w64-i686-gcc-objc mingw32/mingw-w64-i686-lcov mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-gcc-ada mingw64/mingw-w64-x86_64-gcc-fortran mingw64/mingw-w64-x86_64-gcc-libgfortran mingw64/mingw-w64-x86_64-gcc-libs mingw64/mingw-w64-x86_64-gcc-objc mingw64/mingw-w64-x86_64-lcov msys/gcc msys/gcc-fortran msys/gcc-libs msys/mingw-w64-cross-gcc mingw32/mingw-w64-i686-clang mingw32/mingw-w64-i686-compiler-rt mingw32/mingw-w64-i686-lld mingw32/mingw-w64-i686-llvm mingw32/mingw-w64-i686-polly mingw64/mingw-w64-x86_64-clang mingw64/mingw-w64-x86_64-compiler-rt mingw64/mingw-w64-x86_64-lld mingw64/mingw-w64-x86_64-llvm mingw64/mingw-w64-x86_64-polly msys/clang-svn msys/lld-svn msys/llvm-svn mingw32/mingw-w64-i686-gdb mingw32/mingw-w64-i686-gdbm mingw64/mingw-w64-x86_64-gdb mingw64/mingw-w64-x86_64-gdbm msys/cgdb msys/gdb msys/gdbm msys/libgdbm msys/libgdbm-devel msys/cmake autogen automake mingw32/mingw-w64-i686-cmake mingw32/mingw-w64-i686-make mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-make git subversion mingw32/mingw-w64-i686-boost mingw64/mingw-w64-x86_64-boost mingw32/mingw-w64-i686-poco mingw64/mingw-w64-x86_64-poco mingw32/mingw-w64-i686-qemu mingw64/mingw-w64-x86_64-qemu mingw32/mingw-w64-i686-soci mingw64/mingw-w64-x86_64-soci mingw32/mingw-w64-i686-libmariadbclient mingw64/mingw-w64-x86_64-libmariadbclient vim mingw32/mingw-w64-i686-freetds mingw32/mingw-w64-i686-nanodbc mingw32/mingw-w64-i686-unixodbc mingw64/mingw-w64-x86_64-freetds mingw64/mingw-w64-x86_64-nanodbc mingw64/mingw-w64-x86_64-unixodbc mingw32/mingw-w64-i686-emacs mingw64/mingw-w64-x86_64-emacs msys/emacs tar p7zip unrar mingw32/mingw-w64-i686-diffutils mingw64/mingw-w64-x86_64-diffutils msys/diffutils mingw32/mingw-w64-i686-mtex2MML mingw64/mingw-w64-x86_64-mtex2MML msys/bison msys/bisonc++ msys/flexc++ mingw32/mingw-w64-i686-cfitsio mingw32/mingw-w64-i686-flexdll mingw64/mingw-w64-x86_64-cfitsio mingw64/mingw-w64-x86_64-flexdll msys/flex msys/libpipeline
  2. wget.exe http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 && wget.exe http://ftp.gnu.org/gnu/binutils/binutils-2.25.tar.bz2 && wget.exe http://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2 && wget.exe http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2 && wget.exe http://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.bz2 && http://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.bz2

binutils

  1. ../binutils-2.24/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --with-arch=i686 --with-tune=generic --enable-shared --enable-static --enable-libatomic --enable-threads=win32 --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv

安装完后配置fstab,添加/lib。之所以要添加这个是因为如果不配置/lib,后面gcc的configure无法进行下去,会提示 error: C++ preprocessor "/lib/cpp" fails sanity check 的错误,而这个错误是因为找不到/lib/cpp造成的,在日志中会出现: error: /lib/cpp :no such file or direcotry的错误

  1. mkdir /lib
  2. echo "C:/MSYS/MSYS32/mingw32/bin /lib" >> /etc/fstab

执行上面的步骤后,关闭所有命令行

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注