- How to install mingw32 on Ubuntu?
- 3 Answers 3
- mingw installation on Linux
- How To Install gcc-mingw-w64-x86-64 on Ubuntu 18.04
- What is gcc-mingw-w64-x86-64
- Install gcc-mingw-w64-x86-64 Using apt-get
- Install gcc-mingw-w64-x86-64 Using apt
- Install gcc-mingw-w64-x86-64 Using aptitude
- How To Uninstall gcc-mingw-w64-x86-64 on Ubuntu 18.04
- Uninstall gcc-mingw-w64-x86-64 And Its Dependencies
- Remove gcc-mingw-w64-x86-64 Configurations and Data
- Remove gcc-mingw-w64-x86-64 configuration, data, and all of its dependencies
- References
- Summary
- Mingw gcc for linux
- Перед установкой
- Установка
- После установки
- Установка gcc в подсистеме Linux для Windows
- Установка Cygwin
- Установка GCC в Linux
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 .
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?
How To Install gcc-mingw-w64-x86-64 on Ubuntu 18.04
In this tutorial we learn how to install gcc-mingw-w64-x86-64 on Ubuntu 18.04.
What is gcc-mingw-w64-x86-64
MinGW-w64 provides a development and runtime environment for 32- and 64-bit (x86 and x64) Windows applications using the Windows API and the GNU Compiler Collection (gcc).
This package contains the C compiler, supporting cross-compiling to 64-bit MinGW-w64 targets.
There are three ways to install gcc-mingw-w64-x86-64 on Ubuntu 18.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.
Install gcc-mingw-w64-x86-64 Using apt-get
Update apt database with apt-get using the following command.
After updating apt database, We can install gcc-mingw-w64-x86-64 using apt-get by running the following command:
sudo apt-get -y install gcc-mingw-w64-x86-64
Install gcc-mingw-w64-x86-64 Using apt
Update apt database with apt using the following command.
After updating apt database, We can install gcc-mingw-w64-x86-64 using apt by running the following command:
sudo apt -y install gcc-mingw-w64-x86-64
Install gcc-mingw-w64-x86-64 Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.
After updating apt database, We can install gcc-mingw-w64-x86-64 using aptitude by running the following command:
sudo aptitude -y install gcc-mingw-w64-x86-64
How To Uninstall gcc-mingw-w64-x86-64 on Ubuntu 18.04
To uninstall only the gcc-mingw-w64-x86-64 package we can use the following command:
sudo apt-get remove gcc-mingw-w64-x86-64
Uninstall gcc-mingw-w64-x86-64 And Its Dependencies
To uninstall gcc-mingw-w64-x86-64 and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:
sudo apt-get -y autoremove gcc-mingw-w64-x86-64
Remove gcc-mingw-w64-x86-64 Configurations and Data
To remove gcc-mingw-w64-x86-64 configuration and data from Ubuntu 18.04 we can use the following command:
sudo apt-get -y purge gcc-mingw-w64-x86-64
Remove gcc-mingw-w64-x86-64 configuration, data, and all of its dependencies
We can use the following command to remove gcc-mingw-w64-x86-64 configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge gcc-mingw-w64-x86-64
References
Summary
In this tutorial we learn how to install gcc-mingw-w64-x86-64 package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.
Mingw gcc for linux
GNU Compiler Collection (обычно используется сокращение GCC) — набор компиляторов для различных языков программирования, разработанный в рамках проекта GNU. GCC является свободным программным обеспечением, распространяется фондом свободного программного обеспечения (FSF) на условиях GNU GPL и GNU LGPL и является ключевым компонентом GNU toolchain. Он используется как стандартный компилятор для свободных UNIX-подобных операционных систем.
Изначально названный GNU C Compiler поддерживал только язык Си. Позднее GCC был расширен для компиляции исходных кодов на таких языках программирования, как C++, Objective-C, Java, Фортран, Ada, Go, GAS и D.
С версии 4.2.2 GCC перешёл на лицензию GPLv3.
Перед установкой
Проверить, установлен ли gcc можно в cmd командой
Если gcc установлени, Вы увидите версию
Если gcc не установлен, Вы увидите следующее сообщение
Microsoft Windows [Version 10.0.18363.720] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\Andrei>gcc —version ‘gcc’ is not recognized as an internal or external command, operable program or batch file.
Установка
Для работы в Windows нужен MinGW скачать его можно на сайте nuwen.net/mingw.html
Для этой статьи использовался mingw-17.1.exe
Далее действуйте по инструкции
Двойной клик на mingw-17.1.exe
После установки нужно добавить C:\MinGW\bin в системную переменную среды PATH.
Если Вы не знаете как это сделать, прочитайте мою статью «Системная переменная PATH»
Теперь команда gcc —version должна возвращать версию компилятора.
Microsoft Windows [Version 10.0.18363.720] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\Andrei>gcc —version gcc (GCC) 9.2.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Если этого не происходит — перезапустите консоль. Если не помогло — перезапустите Windows.
После установки
Итак, Вы установили MinGW написали простейшую программу 3.cpp, компилируете с помощью gcc
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Andrei\AppData\Local\Temp\ccuoNssB.o:3.cpp:(.text+0x28): undefined reference to `std::ios_base::Init::~Init()’ c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Andrei\AppData\Local\Temp\ccuoNssB.o:3.cpp:(.text+0x58): undefined reference to `std::ios_base::Init::Init()’ collect2.exe: error: ld returned 1 exit status
Если Вы планируете писать софт, который должен будет работать под UNIX-подобными ОС, например Linux или OpenBSD то устанавливать MinGW не стоит.
Попробуйте добавить в Ваш Windows подсистему для Linux и установить gcc там.
Установка gcc в подсистеме Linux для Windows
sudo apt install build-essentials
Установка Cygwin
Если по каким-то причинам Вам не подходят перечисленные выше варианты — установите cygwin cygwin.com
У меня пока что только негативный опыт работы с ним, но у Вас может получиться лучше.
Установка GCC в Linux
В зависимости от типа Linux выполните