Mingw Installation on Linux

How to install mingw32 on Ubuntu?

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.

How do I invoke the MinGW cross-compiler on Linux?

If you look at the file lists on the Ubuntu package webserver for mingw-w64's constituent packages:

  • gcc-mingw-w64-x86-64
  • g++-mingw-w64-x86-64
  • binutils-mingw-w64-x86-64
  • mingw-w64-x86-64-dev
  • gcc-mingw-w64-i686
  • g++-mingw-w64-i686
  • binutils-mingw-w64-i686
  • mingw-w64-i686-dev

You can see that mingw-w64 provides a toolchain, i.e. a set of alternative tools (compiler, linker, headers, etc.) used to compile your code for another system.

Assuming you want to compile C++ code for a 64-bit system, you'll need to use /usr/bin/x86_64-w64-mingw32-g++-win32. You can use the CXX environment variable to tell most Makefiles to use that compiler to compile code.

how do I install both mingw32 and mingw64 on Linux or MacOS?

On Ubuntu, you can get going in many cases with "apt-get install gcc-mingw32"

If you need to install both the 64-bit and 32-bit mingw compilers, try this:

  • from http://sourceforge.net/tracker/?func=detail&aid=3258887&group_id=67079&atid=516781

For 64-bit build systems:

apt-get install libmpfr1ldbl
wget http://ppa.launchpad.net/mingw-packages/ppa/ubuntu/pool/main/w/w64-toolchain/x86-64-w64-mingw32-toolchain_1.0b+201011211643-0w2273g93970b22426p16~karmic1_amd64.deb
dpkg -i x86-64-w64-mingw32-toolchain_1.0b+201011211643-0w2273g93970b22426p16~karmic1_amd64.deb

For 32-bit build systems:

wget http://ppa.launchpad.net/mingw-packages/ppa/ubuntu/pool/main/w/w64-toolchain/i686-w64-mingw32-toolchain_1.0b+201011211643-0w2273g93970b22426p16~karmic1_amd64.deb
dpkg -i i686-w64-mingw32-toolchain_1.0b+201011211643-0w2273g93970b22426p16~karmic1_amd64.deb

Source for this tip: http://ubuntuforums.org/showthread.php?t=1705566

On Fedora, you can install mingw32 using standard yum.
To install mingw64, follow the instructions at:

  • http://fedoraproject.org/wiki/MinGW/CrossCompilerFramework
  • http://fedoraproject.org/wiki/Features/Mingw-w64_cross_compiler
  • http://www.advancedhpc.com/tower_servers/tower_server_products.html

    $ cd /etc/yum.repos.d
    $ sudo wget http://fedoraproject.org/wiki/MinGW/CrossCompilerFramework#Development_and_testing_repository
    $ yum update
    $ yum install mingw64-gcc mingw64-g++ mingw64-zlib

Best bet for cross-compiling seems to be Fedora, which gives you both mingw32 and mingw64:

  • http://fedoraproject.org/wiki/MinGW/CrossCompilerFramework

    sudo yum install mingw32-gcc-c++

I haven't been able to find a 64-bit cross-compiler for Mac.

How to build linux tools via MingW64 in 2021?

There is a way to run ./configure on Windows. You need MSYS2 for that, which will give you a bash shell and the tools needed by ./configure.

MSYS2 comes with a package manager (pacman) which allows you to install a more recent MinGW-w64.

Linux install command for mingw?

If you are running MinGW as a cross-compiler, hosted on Linux, (as your question title might be construed to imply), the native /usr/bin/install on the Linux host itself serves admirably; (FWIW, this is exactly how my own MinGW development platform is set up).

OTOH, if you really mean "where can I find a Linux-like install utility to accompany MinGW running on MS-Windows?", then (as Diego notes) you will find it among MinGW.org's MSYS tools; running mingw-get install msys-base will install it for you, (assuming you are using mingw-get to manage your MinGW installation).



Related Topics



Leave a reply



Submit