是什么 ? | : | GCC for Windows 64 & 32 bits. |
开发语言 | : | C |
官方主页 | : | http://mingw-w64.org |
Win32
程序,不能编译为Win64
程序。MinGW-w64
不仅能编译为Win64
程序,也能编译为Win32
程序。Windows API
。MinGW-w64
的更新很快。操作系统 | 包管理器 | 安装命令 |
---|---|---|
Windows | Chocolatey | choco install -y MinGW |
macOS | HomeBrew | brew install mingw-w64 |
GNU/Linux | HomeBrew | brew install mingw-w64 |
apt | sudo apt-get install -y *-w64-x86-* | |
CentOS | yum | sudo yum install -y mingw-w64-tools mingw32-binutils |
dnf | sudo dnf install -y mingw-w64-tools mingw32-binutils | |
pacman | sudo pacman -Syyu --noconfirm |
step1、安装依赖
所有时 | Terminal + Shell + GNU CoreUtils |
下载时 | cURL |
解压时 | tar + bzip2 |
编译时 | gmake、gcc / GCC | Clang / LLVM |
运行时 | glibc ( libc.so 、libpthread.so 、ld-linux-x86-64.so ) |
step2、使用curl命令下载MinGW-w64
源码包 ()
curl -LO https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v8.0.0.tar.bz2
step3、使用tar解压MinGW-w64
源码包
tar vxf mingw-w64-v8.0.0.tar.bz2
step4、进入mingw-w64-v8.0.0
目录
cd mingw-w64-v8.0.0
step5、查看mingw-w64-v8.0.0
目录中的内容
step6、配置、编译、安装
./configure && make && sudo make install
在GNU/Linux和UNIX系统中,MinGW-w64
提供的命令以${arch}-w64-mingw32-
作为前缀,这是因为这些工具本身是从GCC、GNU BinUtils等项目移植的, 如果不加前缀的话,会与这些软件的命令互相覆盖。
这些命令的用法与GCC、GNU BinUtils等项目中的命令的用法完全一样。
arch | bit |
---|---|
i686 | 32bit |
x86_64 | 64bit |
${arch}-w64-mingw32-gcc | GCC | gcc |
${arch}-w64-mingw32-gcc-ar | GCC | gcc-ar |
${arch}-w64-mingw32-gcc-nm | GCC | gcc-nm |
${arch}-w64-mingw32-gcc-ranlib | GCC | gcc-ranlib |
${arch}-w64-mingw32-g++ | GCC | g++ |
${arch}-w64-mingw32-gcov | GCC | gcov |
${arch}-w64-mingw32-gcov-dump | GCC | gcov-dump |
${arch}-w64-mingw32-gcov-tool | GCC | gcov-tool |
${arch}-w64-mingw32-c++ | GCC | c++ |
${arch}-w64-mingw32-cpp | GCC | cpp |
${arch}-w64-mingw32-as | BinUtils | as |
${arch}-w64-mingw32-ld | BinUtils | ld |
${arch}-w64-mingw32-ar | BinUtils | ar |
${arch}-w64-mingw32-ranlib | BinUtils | ranlib |
${arch}-w64-mingw32-nm | BinUtils | nm |
${arch}-w64-mingw32-strip | BinUtils | strip |
${arch}-w64-mingw32-c++filt | BinUtils | c++filt |
${arch}-w64-mingw32-objcopy | BinUtils | objcopy |
${arch}-w64-mingw32-objdump | BinUtils | objdump |
${arch}-w64-mingw32-readelf | BinUtils | readelf |
${arch}-w64-mingw32-gprof | BinUtils | gprof |
${arch}-w64-mingw32-strings | BinUtils | strings |
${arch}-w64-mingw32-size | BinUtils | size |
${arch}-w64-mingw32-addr2line | BinUtils | addr2line |
${arch}-w64-mingw32-nlmconv | BinUtils | nlmconv |
${arch}-w64-mingw32-dlltool | BinUtils | dlltool |
${arch}-w64-mingw32-windmc | BinUtils | windmc |
${arch}-w64-mingw32-windres | BinUtils | windres |
step1、编写一个C源文件hello.c
,其内容如下:
#include <stdio.h>
int main() {
printf("Hello fpliu\n");
return 0;
}
step2、使用x86_64-w64-mingw32-gcc
命令编译
x86_64-w64-mingw32-gcc -o hello.exe hello.c
step3、使用file命令查看一下hello.exe
的文件格式
step4、使用wine64命令运行hello.exe