Mingw w64 on linux

mingw installation on Linux

I’m currently trying to compile Windows applications on a Linux OS. I need mingw to do this. I read that Debian comes with mingw package already installed. When I run the shell command:

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 gcc-mingw32 - GNU Compiler Collection for MinGW32 (transition package) 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-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 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 libconfig++-dbg - parsing and manipulation of structured config files(C++ debug symbols) libconfig++-dev - parsing and manipulation of structured config files(C++ development) libconfig++9 - parsing and manipulation of structured configuration files(C++ binding) libconfig-dbg - parsing and manipulation of structured config files(debug symbols) libconfig-dev - parsing and manipulation of structured config files(development) libconfig-doc - parsing and manipulation of structured config files(Documentation) libconfig9 - parsing and manipulation of structured configuration files mingw-ocaml - OCaml cross-compiler based on mingw mingw32-ocaml - OCaml cross-compiler based on mingw -- dummy transitional package mingw-w64 - Development environment targetting 32- and 64-bit Windows mingw-w64-dev - Development files for MinGW-w64 (transitional package) 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 mingw32 - Minimalist GNU win32 (cross) compiler mingw32-binutils - Minimalist GNU win32 (cross) binutils mingw32-runtime - Minimalist GNU win32 (cross) runtime 

When I check the /usr/bin/ and /usr/lib for i686-w64-mingw32 I can’t find it anywhere. I’ve also find a search sing find -name «mingw» without much luck. Does Debian come with mingw or do I have to install it? If it does come with mingw how do I use it?

Читайте также:  Linux инструменты для работы с сетью

Источник

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

and downloaded 500 MB of packages, but I cannot find out how to actually run it. There is no mingw executable, so how do I actually compile with it?

If you run the following command from a terminal it should tell you the executable of the compiler ( g++ in this example case ). You can then edit your makefile appropriately. «locate mingw | grep g++»

@gipi In cmake I just issue a «cmake -G «MinGW Makefiles» for compiling on windows and «cmake -G «Unix Makefiles» when compiling on my linux box to have the Makefile built. Is this what you’re after? If not, you’ll need to elaborate 🙂

4 Answers 4

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

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.

There is no variable for toolchain, but you can set variables for C and C++ compilers: CC and CXX respectively.

Another option is to take a look at Mingw Cross Environment (MXE), which is specifically targetting at cross compiling from Linux to Windows (and lately also to Mac). The package has bult-in xupport for a large number of libraries and is actively being developed. Just take a look at the website to find out if it suits your needs.

By the way,it is suggested you use the development rather than the release version. This is because release versions are generally outdated very fast, due to package maintainers (of the libraries) changing URLs resulting in the MXE release version becoming broken. The development version is generally more up-to-date.

There’s no mention about Mac on the website? This seems pretty neat, I’m new to this, so I’m guessing your tool creates the «cross-compiler» first, and then I just have to use your created toolchain to compile things.

Well, it’s not «mine», but that’s pretty much what it does. Not sure about the current state regarding Mac support (I haven’t used mxe in a while). It has been mentioned in the past that they were working on support, but I have no idea if it’s actually been implemented.

Источник

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.

Читайте также:  Python среда разработки линукс

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.

Читайте также:  Linux add library directory

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.

Источник

Оцените статью
Adblock
detector