Yes, you can use a package manager like Yum or pacman to download the latest version of gcc from the internet and then install it using MinGW. Here’s how:
-
Open the MinGW console and navigate to the following directory:
g++ -lm -Wall -Wextra -Werror main.cpp
. This will compile your C/C++ program using GCC, with the default compiler options (e.g., linting, optimization level, warnings turned on, etc.). -
Open a command-line window and type in:
yum download gcc
to install the latest version of gcc from the internet. Make sure you are signed in to your account before this command will work. -
Once you see «Download completed» (or similar), open the downloaded file named «GCC_4.6.2.pkg». You’ll find it in the
C
directory by default. -
Double-click on that file and then copy or cut the provided installer installation files and paste them into the following locations:
-
$MINGW/c /usr/bin (on Windows)
-
/opt/mingw32/bin (on Ubuntu)
-
-
Restart MinGW once you see the progress bar pop up. This will complete the download and installation process, and GCC will be updated automatically. You can now compile your program without any issues.
I hope this helps!
Suppose you are a Health Data Scientist and you have three main software programs (Program A, B and C) that you regularly use to analyze and visualize health data. They all need the latest versions of GCC installed to run properly, and these versions differ slightly:
-
Program A needs version 5.4 of gcc. It also requires MinGW-3.0-2 with specific packages installed in it.
-
Program B needs the latest version 4.9.4 of gcc. And it can function on any compiler, not only MinGW.
-
Program C requires an earlier version than A and B, but all versions of gcc work fine for this program too. It’s important to keep this program running as new data come in.
Given these requirements:
a) How should you install the latest GCC for each program?
b) How can you ensure that you are maintaining the latest version across multiple computers or platforms?
Answer a) For Program A, download the latest version of gcc (5.4) and MinGW-3.0-2 package, then use the commands from step 3 in the original conversation to install them on each computer it needs to work on. For Programs B and C, only the GCC version is needed which can be downloaded at any time.
Answer b) Using a virtual machine or containerized environment such as Docker allows for consistent deployment of code across multiple platforms. This way, you have all programs running on an identical setup in containers that mirror the one on a single system.
UPDATE: As of Nov-5-2012, MinGW includes 4.7.2 of the GCC compiler, which is the most current version. I personally will use the MinGW package, since it includes MSYS and other tools, and since it is the defacto standard, I hope that it is better supported. The only drawback is the included GDB does not include Python scripting, but I think that can be updated separately.
I don’t know if you can update the GCC in MinGW, but there are alternative projects to MinGW with newer versions of GCC.
The MinGW-builds project provides a package similar to MinGW but with an updated GCC (4.7.2). I extracted the files to c:\MinGW (so I could use the same path) after moving my existing MinGW to another folder. Only MinGW has MSYS, so if you need that (I did) copy the msys folder from the original MinGW.
After installing MinGW-builds, the result of g++ —version:
g++ (Built by MinGW-builds project) 4.7.2
The latest GCC that comes with standard MinGW is currently 4.7.0. I compiled a few simple projects in Code::Blocks, and the latest wxWidgets source, and everything seems to work.
It’s worth noting that MinGW-builds includes a Python script enabled version of GDB, in case you want STL pretty printer support, or other GDB Python features.
Another good choice is TDM-GCC, which is a project that hosts an impressive installer that includes an updated GCC compiler (4.7.1) and support tools. It is a standalone package. As far as I can tell, Python scripting is not supported in the GDB that comes with this package.
Finally there is the MinGW-w64 project, which is a fork of MinGW. Rubenvb, who posted an answer to this question, has good standalone packages (in the personal builds folder) based on this project which include an updated GCC (4.7.2). The included GDB seems to be Python script enabled.
The Cygwin 1.7.x devel area offers an older version of GCC (3.4.4-999), which is outdated for many purposes. (GCC 4.5.3-4 is also offered in the gcc4 package, but the Cygwin 1.7.x devel area does not offer GCC 4.6 or later). This article describes how to upgrade your Cygwin GCC installation to a more recent version (e.g., 4.6.1).
Alternatively, MinGW can be installed alongside Cygwin. By editing the Cygwin path, calls to gcc or g++ can point to the MinGW bin directory.
Follow the links to learn more about the GCC 4.6 release series and the GCC 3.4 release series.
Problems? For discussion and mention of user- or system-specific issues, please use the «Talk» button above.
Disclaimer[]
This how-to is provided without any guarantees whatsoever. This process was tested using the versions of Cygwin and the prerequisite packages listed below.
Warning[]
After you install GCC >= 4.3, some things like exception handling or shared code may not work (read more here), so install at your own risk. (The new GCC will be installed under /usr/local/bin; you’ll still have the old GCC under /usr/bin or /bin).
Verify Cygwin Prerequisites[]
Check that you have following packages under Cygwin. If something is missing or outdated, download it using the setup.exe utility from the Cygwin site (http://cygwin.com/):
- bash (found in the Base section)
- gzip (version 1.2.4 or later; found in the Base section)
- binutils (found in the Devel section)
- bzip2 (version 1.0.2 or later; found in the Utils section)
- gcc-core (or any other C compilier; found in the Devel section)
- gcc-g++ (needed only if you want to install c++ compilier; found in the Devel section)
- gcc-ada (needed only if you want to install Ada compilier; any version; found in the Devel section)
- m4 (found in the Interpreters section)
- make (version 3.79.1 or later; found in the Devel section)
- Either/or:
- zip and unzip (needed only if you want to install Java; found in the Archive section)
- gcc-java (needed only if you want to install Java; only jar command is needed; found in the Devel section)
You can check package version numbers and statuses with the cygcheck command:
cygcheck -c \ bash binutils bzip2 cygwin gcc-core gcc-g++ gcc-java gzip m4 make unzip zip
An example of the ‘Cygwin Package Information output:
Package Version Status bash 4.1.10-4 OK binutils 2.20.51-2 OK bzip2 1.0.6-1 OK cygwin 1.7.9-1 OK gcc-core 3.4.4-999 OK gcc-g++ 3.4.4-999 OK gzip 1.4-1 OK m4 1.4.16-1 OK make 3.81-2 OK unzip 6.0-10 OK zip 3.0-11 OK
Gather GCC and Its Prerequisites[]
First, create a workspace directory to build in (e.g., mkdir /usr/local/contrib). This is where you’ll extract and work with each GCC-related package, including GCC itself.
Gather the GCC prerequisite packages:
- Go to http://gmplib.org/ and download the source (e.g., gmp-5.0.2.tar.bz2). GMP is a library for arbitrary precision arithmetic. It is required for MFPR and thus for GCC. The version from Cygwin is older and will not work.
- Go to http://mpfr.org/ and download the source (e.g., mpfr-3.0.1.tar.bz2). MPFR is a library for arbitrary precision floating-number arithmetic which produces exactly same results for any CPU or operating systems. It is required for GCC.
- Go to http://www.multiprecision.org/ and download the source (e.g., mpc-0.9.tar.gz). MPC is a library for arbitrary precision complex number arithmetic and is required for GCC.
- Go to http://gcc.gnu.org/mirrors.html, select a working mirror, browse to the gcc folder and the version numbered subfolder, and download the full GCC tarball for that version (e.g., gcc-4.6.0.tar.bz2) You will see MANY things in a given GCC version’s folder… the main archive will contain everything you need.
Check Environment Variables[]
The environment variables LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH must be set correctly:
- LD_LIBRARY_PATH and LIBRARY_PATH should contain /usr/local/lib (LIBRARY_PATH shall not be set on Enterprise Linux Enterprise Linux Server release 5.5 (cartage))
- CPATH should contain /usr/local/include
- If PATH contains c:/windows/system32 (or /cygdrive/c/windows/system32; case-insensitive), it should be after /bin and /usr/bin. Otherwise the scripts will try to run Windows sort.exe instead of the Unix command with the same name.
Viewing settings (paste all the lines — works in either shell):
echo ;\ echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}; \ echo LIBRARY_PATH=${LIBRARY_PATH}; \ echo CPATH=${CPATH}; \ echo PATH=${PATH}; \ echo
Settings example (bash):
export LD_LIBRARY_PATH=/usr/local/lib # Depending on system, LIBRARY_PATH shall not be set - # export LIBRARY_PATH= export LIBRARY_PATH=/usr/local/lib export CPATH=/usr/local/include export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
Settings example (csh/tcsh):
setenv LD_LIBRARY_PATH /usr/local/lib setenv LIBRARY_PATH /usr/local/lib setenv CPATH /usr/local/include setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
These settings should also should be included into your .bash_profile or .profile (if you use bash) or .cshrc / .tcshrc (if you use csh/tcsh).
Pre-Build Notes[]
The make utility has the «-j n» option for parallel build jobs, where «n» = the maximum number of jobs to spread the build across. Running it as
make -j 2 ...
can significantly speed up the build, particularly on multi-core/hyper-threaded processors. Generally it is best to keep n <= the number of real or virtual cores you have (in other words, if you have a quad core and try running -j 20 you may not be doing yourself any favors over -j 8 or possibly even -j 4, and might have other problems such as excessive swap usage that negate any possible speed improvement).
Beware: sometimes multi-job builds can fail or hang (if the build hangs for a few minutes with zero CPU being used by various, unchanging build sub-processes, as seen in Process Explorer or Task Manager, this suggests a possible deadlock).
Also, if you have Spybot Search & Destroy installed, its TeaTimer functionality will slow down the build/install process. You may want to disable it or kill it in Task Manager for the duration of this build/install process.
A Special Note about Logging Your Build[]
You’ve spent a few hours building and something goes wrong. Logging your build (or ANY non-interactive command’s output) is a quick and painless sanity-saver when you know what to do!
For bash:
somecommand -someargs -moreargs -yougettheidea 2>&1 | tee mylogfile.log
For csh/tcsh:
somecommand -someargs -moreargs -yougettheidea |& tee mylogfile.log
Build and Install GCC’s Prerequisites[]
Perform the following build/install steps for the GMP, MPFR and MPC packages in that order:
- cd to your workspace directory (above, e.g., cd /usr/local/contrib)
- Extract the tarball using tar (e.g., tar -xf gmp-5.0.2.tar.bz2). This will create a sub-folder with the source for the given package
- cd into that source folder (e.g., cd gmp-5.0.2)
- Read the README and/or INSTALL file if present (but that’s why you’re here after all…)
- Run ./configure (this will check the configuration of your system for the purpose of this package)(you also need specify —enable-static —disable-shared when compiling the library)
- Run make (this will build the package; -j can speed things up here)
- Run make check (strongly recommended but optional; this will check that everything is correct — special caveat for the GCC package itself, below)
- Run make install (this will install all the relevant files to the relevant directories)
- Run make clean (optional; this will erase intermediate files — important if you are re-attempting a broken build!)
- Note that for the current versions of gmp (5.0.5) and mpc (0.9) two changes need to be made to have the build work successfully. In the gmp configure file there are two lines
ln -s $ac_rel_source $ac_dest 2>/dev/null || ln $srcdir/$ac_source $ac_dest ||
You need to comment out the first one so it looks like this.
#ln -s $ac_rel_source $ac_dest 2>/dev/null || ln $srcdir/$ac_source $ac_dest ||
The second change is to mcp, in the mpc-0.9/src folder you need to edit the line of «mpc.h»
#if defined(__MPC_WITHIN_MPC) && __GMP_LIBGMP_DLL
to
#if defined __GMP_LIBGMP_DLL
Build and Install GCC[]
Perform the following build/install steps for GCC (note how this differs significantly from the instructions above!):
- cd to your workspace directory (above, e.g., cd /usr/local/contrib)
- Extract the tarball using tar (e.g., tar -xjf gcc-4.6.0.tar.bz2). This will create a sub-folder with the source for the given package. This might take significantly longer than the other packages, so be patient.
- YOU MUST NOT ATTEMPT TO BUILD GCC FROM SOURCE DIR.
- Instead create a new build folder at same level. Create a build folder (e.g., mkdir build) in your workspace. Thus you will have the gcc-4.6.0 folder and build folder at the same directory level.
- cd into the build folder (e.g., cd build)
- You may want to read the README and/or INSTALL file if present
- Run ../gcc-*/configure —enable-threads=win32 —enable-languages=c,c++ (The «—enable-languages» option specifies here to build gcc (the C compiler) and g++ (the C++ compiler). GCC actually includes many languages. If you leave out this option you’ll build all of them, which could easily take 4 hours or so. See the GCC configuration page for details. If you’ll need to install multiple versions of GCC, you’ll want to use the —prefix argument so they don’t all end up in /usr/local. See the configure —help output for details.)
- Run make (this will build the package; -j can speed things up here — this will take a while even with that!) The comparison step between stage 2 and 3 takes a particularly long time… it’ll seem hung but your process/task monitor will show activity. The two specific warnings «gcc/cc1-checksum.o differs» and «gcc/cc1plus-checksum.o differs» are not unusual and should not themselves cause a build failure (the «compare:» target in build/Makefile specifically manages this).
- Skipping make check: For GCC on Cygwin we CANNOT run make check! (You cannot perform the make check step because it requires autogen which in turn requires libguile which in turn requires libtool. If you would try to install libtool, guile, and autogen, then you will see that guile (v 1.8.4) has some problems (fails 2 tests of 64) and autogen (v 5.9.4) does not work (fails 18 tests of 20)).
- Run make install (this will install all the relevant files to the relevant directories)
- Run make clean (optional; this will erase intermediate files — important if you are re-attempting a broken build!)
After GCC is Built and Installed[]
The new GCC will be installed under /usr/local/bin, while /bin/gcc and /usr/bin/gcc will still point to the original Cygwin GCC. If you want to use new GCC by default, make sure that your path contains /usr/local/bin before /bin and /usr/bin
You may view your path using
printenv PATH
Run a quick sanity test:
echo; gcc --version; echo; g++ --version; gcc (GCC) 4.6.0 Copyright (C) 2011 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.
g++ (GCC) 4.6.0 Copyright (C) 2011 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 EVER.
Last edited[]
MartyMacGyver 21:36, July 10, 2011 (UTC)
Before you update Mingw on Windows, you should first check its version. You can download an older version of the tool from the internet, or buy it on CDs. But be aware that older versions may contain more bugs and are harder to use. If you’re experiencing problems with installation or use, you should see if there’s an updated version available. Run the command gcc -dumpversion to see what version you’re using.
You can also download the self-hosted version of Mingw, which provides additional support for Microsoft.lib library files. However, you should note that this version may not be fully compatible with all versions of Windows. You can also install other compilers in addition to Mingw on your system, which will require you to update them as well. The update process is simple, but you should check which compilers are compatible with it.
How Do I Install the Latest Version of MinGW?
To install the latest version of MinGW, you should go to the bin folder on the C drive. After downloading the file, you should move it to a permanent location. This way, you can install MinGW later. Next, you should change the location of your environment variables. To do this, open the control panel and go to Advanced system settings. In the Advanced system settings, look for the Environment variables.
MinGW is an open source compiler and linker. It uses MSVCRT, a library that was released with the Windows operating system. It lacks support for C99 features and some C89 APIs. This makes it difficult to port programs. Fortunately, there is a C99 compatibility library called libmingwex. Fortunately, this library resolves printf issues.
After installing the MinGW, you can start compiling your project. You should see a message similar to the one below. You should also see a message saying that you have successfully installed gcc and gfortran version 5.3.0-3. If the MinGW installer tells you that the installation was successful, it’s a good sign. If you have trouble with it, you can try installing the older version of MinGW by following the steps below.
What is Latest Version of MinGW?
If you are wondering What is Latest Version of MinGW on Windows, you need to make sure you install the newest version. You can do this by going to the MinGW website and selecting download. You will then need to specify your system environment. The target environment is Windows 7/64 or Linux. Typically, you will want to install MinGW for Windows on Windows 7.
Cygwin provides a full implementation of all major Unix system calls. However, the main difference between MinGW and Cygwin is that Cygwin prioritizes compatibility over performance. MinGW focuses on simplicity and performance. You do not need to download Cygwin to install MinGW. Both programs are portable to other operating systems. MinGW is also supported on 64-bit machines. However, Cygwin is much more stable than MinGW.
How Do I Download MinGW 2021?
If you are wondering how to download MinGW for Windows, you are not alone. There are several ways to do so, and this article will give you all of the details that you will need. This guide will work for all versions of Windows, regardless of the operating system you are using. The first step is to download the program itself. You can download MinGW by going to the Control Panel and typing “env”. Then, navigate to the System section and select “Edit user variables.” Here, you will find the Environment variable. Enter the path to the folder where you want to install MinGW and click OK.
After downloading the application, you can install it on your computer. Open the MinGW installation manager. This program will show you the progress of the download. Click on the ‘Compatibility Mode’ tab and select ‘Enable 32-bit support’. Once the installation is complete, you can start programming. MinGW is an excellent development tool that is available for free. However, you will need to pay close attention to the installation process, since this program is quite large.
What is the Latest Version of Gcc?
If you want to know what is the latest version of GCC, you’ll first have to know what package it is. You can tell if a package is loaded by running gcc -v. This command will tell you the latest version that is currently installed on your computer. GCC is a widely used compiler, and you can find a variety of versions on different platforms. However, if you’re not sure which version to download, here are some simple steps:
For those who use Windows, you can use the gcc 2.6 or 2.7. If you are using a version earlier than 2.7.2, you should upgrade your system. If you need to use C++ features like egcs, you’ll want to use g++ version 2.8.1. However, if you are using a non-Unix platform, you may have to go for the older gcc version. Be sure to use the same libg++ version as well.
To install MinGW on Windows 10, go to control panel, open Advanced system settings, and choose the Environment variables option. Change the value to C:MinGWbin. Depending on your operating system, you may need to change the path for your environment variable to a different location. The path will contain the path of the bin folder you want to install MinGW to. Once you have the path, open the program and double-click on the MinGW icon. The MinGW window will appear.
Once you have installed MinGW, you can use it to compile your GNU programs on Windows. MinGW supports both static and dynamic libraries and follows the lib name.a naming convention similar to those found on Unix-like systems. Windows system headers and static import libraries are released under the GNU General Public License (GPL), and you can download the binary versions from the MinGW website. For further information, visit the official MinGW website.
How Do I Know If MinGW is Installed?
To check if MinGW is installed on your Windows computer, open the control panel and select the Environment Variables option. In the Environment Variables window, change the compilerPath to “MinGW-w64”. Click on the Add button. The MinGW w64 path should now appear in the Windows registry. If you do not see MinGW on your PC, you can install it manually.
MinGW is an open-source C++ compiler and POSIX build environment. It compiles code to run on Win32 systems and provides C++, C, and Fortran compilers. MinGW is also known as mingw32 and mingw. Both are the same compiler system. Both will eventually be ported to 64-bit systems. If you don’t have a MinGW-based Windows machine, follow the instructions below to install it.
What Happened to MinGW?
If you’re wondering: “What happened to MinGW on Windows?” you’re not alone. Almost everyone is wondering this as well, and if you don’t have a clue how to fix this problem, this article is for you. MinGW is an excellent cross-compiler that targets native Windows APIs. It’s also free of problems like nesting recursively, exposing drive letter directories, and so on.
Learn More Here:
1.) Windows Help Center
2.) Windows – Wikipedia
3.) Windows Blog
4.) Windows Central
UPDATE (6/24/12): I’ve updated instruction on how to get Qt working also, Please use that article here, if you’d like full functionality.
I wanted to play with c++11 features while using Qt Creator as my IDE. Here are the steps:
1.) download “mingw32-gcc-4.6.2-release-c,c++,fortran-sjlj-FINAL.zip” from http://code.google.com/p/mingw-builds/downloads/list (They recommend the latest with the FINAL keyword at the end).
2.) Make a copy of C:\QtSDK\mingw just incase something didn’t go right or you have to revert to it in the future.
3.) Extract the zip to C:\QtSDK\mingw
4.) Launching the qt mingw command prompt and running g++ –version should now show the version you downloaded and extracted:
C:\>g++ --version g++ (niXman build) 4.6.2 Copyright (C) 2011 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.
5.) Compiled this test code below to see if c++11 features were working:
g++ -std=gnu++0x test.cpp && a.exe
#include <iostream> #include <vector> #include <memory> /* Delgating constructors isn't implemented in gcc 4.6! */ /* class Multiply { int m_var; int m_mult; public: Multiply(int var, int mult) { m_var = var; m_mult = mult; } Multiply(int mult) : Multiply(mult, mult) { } int calc() const { return m_var * m_mult; } }; */ struct Test { int a; int b; std::string c; }; void printTest(Test t) { std::cout << t.a << "\t" << t.b << "\t" << t.c << std::endl; } std::string* createNewString() { return new std::string(u8"Hello World! Unicode Character: \u2018"); } int main(int argc, char** argv) { std::vector<int> test = {1, 2, 3, 4, 5}; for (auto& x : test) std::cout << x << std::endl; printTest({test.at(3),2,"Hello World!"}); std::shared_ptr<std::string> test_str(createNewString(), [](std::string* ptr) { delete ptr; }); std::cout << test_str << ":\t" << *test_str << std::endl; return 0; }
output:
1 2 3 4 5 4 2 Hello World! 0x581458: Hello World! Unicode Character: ‘
The Qt SDK should probably be recompiled when using a different compiler version, I can’t make any guarantees this will work 100% but should be enough to play with c++11!