How to install mingw32 on Ubuntu?
Asked Answered
M

3

20

I would like to install mingw32 on my Ubuntu (16.10) cuz I would like to generate an x86 windows version of my application. The "i586-mingw32msvc-g++" executable is needed by my Makefile (CMake).

I tried "sudo apt install mingw32" but it doesn't work (I have a "package not found" error).

Melan answered 6/6, 2017 at 12:25 Comment(0)
L
34

Look more closely at what is actually available:

edd@max:~$ apt-cache search mingw-
libassuan-mingw-w64-dev - IPC library for the GnuPG components -- Windows port
libgcrypt-mingw-w64-dev - LGPL Crypto library - Windows development
libgpg-error-mingw-w64-dev - library of error values and messages in GnuPG (Windows development)
libksba-mingw-w64-dev - X.509 and CMS support library (Windows development)
libnpth-mingw-w64-dev - replacement for GNU Pth using system threads (Windows dev)
binutils-mingw-w64 - Cross-binutils for Win32 and Win64 using MinGW-w64
binutils-mingw-w64-i686 - Cross-binutils for Win32 (x86) using MinGW-w64
binutils-mingw-w64-x86-64 - Cross-binutils for Win64 (x64) using MinGW-w64
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
g++-mingw-w64-i686 - GNU C++ compiler for MinGW-w64 targeting Win32
g++-mingw-w64-x86-64 - GNU C++ compiler for MinGW-w64 targeting Win64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
gcc-mingw-w64-base - GNU Compiler Collection for MinGW-w64 (base package)
gcc-mingw-w64-i686 - GNU C compiler for MinGW-w64 targeting Win32
gcc-mingw-w64-x86-64 - GNU C compiler for MinGW-w64 targeting Win64
gdb-mingw-w64 - Cross-debugger for Win32 and Win64 using MinGW-w64
gdb-mingw-w64-target - Cross-debugger server for Win32 and Win64 using MinGW-w64
gfortran-mingw-w64 - GNU Fortran compiler for MinGW-w64
gfortran-mingw-w64-i686 - GNU Fortran compiler for MinGW-w64 targeting Win32
gfortran-mingw-w64-x86-64 - GNU Fortran compiler for MinGW-w64 targeting Win64
gnat-mingw-w64 - GNU Ada compiler for MinGW-w64
gnat-mingw-w64-base - GNU Ada compiler for MinGW-w64 (base package)
gnat-mingw-w64-i686 - GNU Ada compiler for MinGW-w64 targeting Win32
gnat-mingw-w64-x86-64 - GNU Ada compiler for MinGW-w64 targeting Win64
gobjc++-mingw-w64 - GNU Objective-C++ compiler for MinGW-w64
gobjc++-mingw-w64-i686 - GNU Objective-C++ compiler for MinGW-w64 targeting Win32
gobjc++-mingw-w64-x86-64 - GNU Objective-C++ compiler for MinGW-w64 targeting Win64
gobjc-mingw-w64 - GNU Objective-C compiler for MinGW-w64
gobjc-mingw-w64-i686 - GNU Objective-C compiler for MinGW-w64 targeting Win32
gobjc-mingw-w64-x86-64 - GNU Objective-C compiler for MinGW-w64 targeting Win64
libz-mingw-w64 - compression library - Windows runtime
libz-mingw-w64-dev - compression library - Windows development files
mingw-ocaml - ocaml-mingw-w64 transitional dummy package
mingw-w64 - Development environment targeting 32- and 64-bit Windows
mingw-w64-common - Common files for Mingw-w64
mingw-w64-i686-dev - Development files for MinGW-w64 targeting Win32
mingw-w64-tools - Development tools for 32- and 64-bit Windows
mingw-w64-x86-64-dev - Development files for MinGW-w64 targeting Win64
ocaml-mingw-w64 - OCaml cross-compiler based on mingw -- Meta-package
ocaml-mingw-w64-i686 - OCaml cross-compiler based on mingw -- 32 bit compiler
ocaml-mingw-w64-x86-64 - OCaml cross-compiler based on mingw -- 64 bit compiler
edd@max:~$

So sudo apt-get install gcc-mingw-w64 is probably what you want, and you should get a 32-bit executable built by setting the appropriate compiler option, likely -m32.

Licentiate answered 6/6, 2017 at 12:28 Comment(4)
typo in package name to install (old: gcc-mingw-64 new: gcc-mingw-w64)Nannette
@Nannette I have fixedTigrinya
mingw-w64 is actually not mingw32 (see #25582610), but becauset he OP probably just wants a working cross-compiler, not actual mingw32, this still is the correct answerEquilibrate
So you can probably install the gcc-mingw-w64-i686 package if you want strict 32-bit compilerTijerina
S
6

I tried sudo apt-get install gcc-mingw-w64.

And then I compile the code with the command :

i686-w64-mingw32-gcc-win32 input_code.c -o output.exe
Stulin answered 7/9, 2021 at 12:32 Comment(0)
E
0

if you have a trouble at remembering the name of compiler, you can trying to use an alias on linux system you can modified from .bashrc

so the location of mingw is here -> /usr/bin/i686-w64-mingw32-gcc-win32

on down below you can create like this for simplify mingw compiler:

alias mingw=/usr/bin/i686-w64-mingw32-gcc-win32
Embitter answered 18/4, 2023 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.