Installing mingw on linux

How to install mingw32 on ubuntu in Linux?

MinGW (Minimalist GNU for Windows) is a software development environment to create Microsoft Windows applications. MinGW is an open-source alternative to Microsoft Visual C++ and provides a more lightweight environment for developing Windows applications on other operating systems like Linux. In this tutorial, we will show you how to install MinGW 32-bit on Ubuntu 20.04 LTS.

Method 1: Installing MinGW on Ubuntu using apt-get

To install MinGW on Ubuntu using apt-get, follow these steps:

  1. Open a terminal window by pressing Ctrl+Alt+T or searching for «Terminal» in the Applications menu.
  2. Update the package list on your system by running the following command:
sudo apt-get install mingw-w64
mingw32-gcc source-file> -o output-file>

That’s it! You now have MinGW installed on your Ubuntu system and can use it to compile C and C++ programs.

Method 2: Installing MinGW on Ubuntu using source code

This guide provides step-by-step instructions on how to install MinGW on Ubuntu using source code. MinGW is a Windows development toolchain for Linux, which allows developers to compile and build Windows applications on Linux.

Before proceeding with the installation, make sure that your Ubuntu system is up-to-date and has the necessary build tools installed. To do this, open a terminal and run the following commands:

sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential
  1. Download the MinGW source code from the official website: http://www.mingw.org/
  2. Extract the downloaded archive to a directory of your choice:
./configure --prefix=/usr/local/mingw --host=i686-w64-mingw32
export PATH=$PATH:/usr/local/mingw/bin
i686-w64-mingw32-gcc -o hello.exe hello.c

Источник

Downloads

The heart of the Mingw-w64 project is headers and support libraries to run the output of GCC on Windows. Since Mingw-w64 is neither the home of GCC nor of binutils, several sets of installation packages which combine them are available.

In addition, the sources are available but most people will want to grab binaries directly.

Pre-built toolchains and packages

Version Host GCC / Mingw-w64 Version Languages Additional Software in Package Manager

Arch Linux
Arch Linux 12.2.0/ 10.0.0 Ada, C, C++, Fortran, Obj-C, Obj-C++ many

Cygwin
Rolling Windows 11.3.0/10.0.0 C, C++, Fortran, Obj-C many

Debian
Debian 9 (Stretch) 6.3.0/5.0.1 Ada, C, C++, Fortran, Obj-C, Obj-C++, OCaml 9 (gdb, libassuan, libgcrypt, libgpg-error, libksba, libnpth, nsis, win-iconv, zlib)
Debian 10 (Buster) 8.3.0/6.0.0 Ada, C, C++, Fortran, Obj-C, Obj-C++
Debian 11 (Bullseye) 10.2.1/8.0.0

Fedora
Fedora 36 11.2.1/9.0.0 Ada, C, C++, Fortran, Obj-C, Obj-C++ many
Fedora 37 12.2.1/10.0.0
LLVM-MinGW 20220906 Windows, Linux LLVM 15.0.0/trunk C, C++ make, Python
w64devkit 1.19.0 Windows 13.1.0/11.0.0 C, C++, Fortran 8 (busybox, cppcheck, ctags, gdb, make, nasm, pkg-config, vim)

MacPorts
Rolling macOS 12.2.0/ 10.0.0 C, C++, Fortran, Obj-C, Obj-C++ 1 (nsis)
MingW-W64-builds Rolling Windows 13.1.0/11.0.0 C, C++, Fortran 4 (gdb, libiconf, python, zlib)

MSYS2
Rolling Windows 13.1.0/ trunk Ada, C, C++, Fortran, Obj-C, Obj-C++, OCaml many
WinLibs.com Rolling Windows 12.2.0 Ada, C, C++, Fortran, Obj-C, Obj-C++, Assembler Package manager: work in progress (will offer > 2500 packages)

Ubuntu
18.04 Bionic Beaver 7.3.0/5.0.3 Ada, C, C++, Fortran, Obj-C, Obj-C++ 9 (gdb, libassuan, libgcrypt, libgpg-error, libksba, libnpth, nsis, win-iconv, zlib)
20.04 Focal Fossa 9.3.0/7.0.0
22.04 Jammy Jellyfish 10.3.0/8.0.0
22.10 Kinetic Kudu 10.3.0/10.0.0
23.04 Lunar Lobster 12.2.0/10.0.0

Arch Linux

Ubuntu

Installation: through integrated package manager.

Cygwin

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Its core is the cygwin1.dll library which provides POSIX functionality on top of the Win32 API. It can be used as a build environment which targets Windows directly and for which output doesn’t depend on cygwin1.dll.

Installation is done through cygwin’s package manager: setup.exe.

As part of the numerous packages in cygwin, there are cross-compilation toolchains which target both 32 bits and 64 bits; their names start with “mingw64-”.

Once they are installed, they should be used according to the general cross-compilation approach.

Debian

Installation: through integrated package manager.

Fedora

Installation: through integrated package manager.

LLVM-MinGW

LLVM-MinGW is a toolchain built with Clang, LLD, libc++, targeting i686, x86_64, arm and aarch64 (ARM64), with releases both for running as a cross compiler from Linux and for running on Windows. It supports Address Sanitizer, Undefined Behaviour Sanitizer, and generating debug info in PDB format.

w64devkit

w64devkit is a portable C and C++ development kit for x64 (and x86) Windows.

  • Mingw-w64 GCC : compilers, linker, assembler
  • GDB : debugger
  • GNU Make : standard build tool
  • busybox-w32 : standard unix utilities, including sh
  • Vim : powerful text editor
  • Universal Ctags : source navigation
  • NASM : x86 assembler
  • Cppcheck : static code analysis

The toolchain includes pthreads, C++11 threads, and OpenMP. All included runtime components are static.

MacPorts

To install just the 32-bit or just 64-bit compiler with dependencies, use:

sudo port install i686-w64-mingw32-gcc sudo port install x86_64-w64-mingw32-gcc 

A shortcut to install both:

sudo port install mingw-w64 

Mingw-builds

WinLibs.com

Standalone MinGW-w64+GCC builds for Windows, built from scratch (including all dependencies) natively on Windows for Windows.

Downloads are archive files ( .zip or .7z ). No installation is required, just extract the archive and start using the programs in mingw32\bin or mingw64\bin . This allows for a relocatable compiler suite and allows having multiple versions on the same system.

Also contains other tools including: * GDB — the GNU Project debugger * GNU Binutils — a collection of binary tools * GNU Make — a tool which controls the generation of executables and other non-source files * Yasm — The Yasm Modular Assembler Project * NASM — The Netwide Assembler * JWasm — A free MASM-compatible assembler

Flavors: * separate packages for 32-bit (i686) and 64-bit (x86_64) Windows * separate packages for MSVCRT and UCRT builds * only POSIX threads builds (which also include Win32 API thread functions) * exception model: Dwarf for 32-bit (i686) and SEH for 64-bit (x86_64)

Installation: Download from winlibs.com and extract archive (no installation needed).

MSYS2

Sources

Tarballs for the mingw-w64 sources are hosted on SourceForge.

The latest version from the 11.x series is 11.0.0.

The latest version from the 10.x series is 10.0.0.

The latest version from the 9.x series is 9.0.0.

The latest version from the 8.x series is 8.0.2.

The latest version from the 7.x series is 7.0.0.

The latest version from the 6.x series is 6.0.0.

The latest version from the 5.x series is 5.0.4.

The old wiki has instructions for building native and cross toolchains.

Details on how to get the mingw-w64 code from Git and an Git-web viewer are available on SourceForge.

Unsorted complementary list

Darwin/Mac OS X

The existing Darwin binaries have been built through buildbot in 2013 and links to them can be found on the dedicated page.

OpenSUSE

The OpenSUSE Linux distribution also has a large and well-maintained set of packages for cross-compilation.

Rubenvb

Rubenvb has built a number of toolchains including some for less common setups. They are split into two categories: toolchains targeting Win32 or Win64.

GCC with the MCF thread model

GCC with the MCF thread model is a series of x86 and x64 native toolchains built by LH_Mouse. The MCF thread model involves the mcfgthread library to provide minimum yet complete C++11 thread support. Disregarding POSIX or Windows XP compatibility, it implements (hopefully the most) efficient mutexes and condition variables that are competitive with even native slim reader/write (SRW) locks and condition variables since Windows Vista.

Store of binaries on SourceForge

A very large number of other binaries and sources are hosted in the File Release System on Sourceforge which might have what you are after.

Источник

How to install mingw32 on Ubuntu?

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).

3 Answers 3

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 .

Источник

Читайте также:  Apple magic trackpad linux
Оцените статью
Adblock
detector