How can I use GCC-7.1.0 on Windows? - c++

C++17 is coming out, and I'm hoping to use it in some upcoming projects. How can I install GCC-7.1.0 on windows without relying on Cygwin? I have a version of mingw already installed on my computer, and I've downloaded and unpacked the folder containing the source code for gcc-7.1.0. How can I use my current version of the gcc compiler to compile gcc-7.1.0? Is there a sequence of commands I can carry out in the windows command prompt to do this?

The easiest way to install a recent GCC is to use the MinGW distribution provided by Stephan T. Lavavej at https://nuwen.net/mingw.html
He provides a download of precompiled-binaries as well his build script. So you can either download the current version or use his build scripts to compile your chosen version.

Related

Build gcc on Windows with another gcc version

How to compile the newest gcc release under Windows 10? I have the latest mingw-w64available here which isn't fully c++17 compliant (I cannot use the filesystem library). A build called winlibs is also available but it is built on mingw-w64 8.0.0, so newer standards aren't fully supported. I downloaded the compressed file gcc-10.3.0.tar.gz.
What are the steps needed to do build any new (or old) gcc release on Windows natively without resorting to cygwin or msys or wsl?
Building GCC isn't trivial. It involves multiple steps, starting with having all the dependancies available.
You already had an older winlibs release, who don't you just get the latest winlibs build from http://winlibs.com/ ?
I do not understand what problem you are having with std::filesystem. Perhaps you are using a different mingw. Here is how I get mingw64
Download and install the latest g++ 64 bit compiler from
http://www.msys2.org/ Follow installation instructions on that page.
Note that you will have to stop and restart the MSYS2 command line
tool several times. To do this, close the window and then run
C:\msys64\msys2_shell. When pacman ( packet manager ) reports "there
is nothing to do" run it once more with the command pacman -S
mingw-w64-x86_64-toolchain

Difference between the windows installation of minGW64 and the MSYS2 shell installed version of minGW64

I have been using the minGW64 compiler with Visual studio code on windows for some time. However, there are certain limitations to it when it comes to certain libraries. The absence of a make tool and the inability to execute a config script while compiling a c++ program being the main ones. I came to know of MSYS, a tool provides a UNIX environment that allows us to do certain things that are forbidden by the windows terminal. I installed it but I saw that I need to install mingw64 again, from within the terminal to use it with MSYS2.
My question is, is there no way I can use my earlier mingw copy with this installation of MSYS2? Is there some difference between the mingw64 that comes with MSYS2 and the standard installation?

Current Cygwin version is not supported by Clion, how to install an earlier version of it?

I am trying to get my Clion 1.1.1 to work with Cygwin. I've installed Cygwin using its setup-x86_64.exe installer. but when I set Cygwin path in Clion's toolchains dialog, it says:
Environment: Cygwin; current version is 2.2.1; supported version range is 1.7.32-2.0.x
On the Cygwin website there is a snapshots page, in which packages are sorted by date (not version) and in faq page it says:
If you are looking for the version number for the whole Cygwin release, there is none. Each package in the Cygwin release has its own version.
So, if there is no version number for whole Cygwin release, what is Clion complaining about?
and if there is, how can I install an earlier version?
afaik, you'll either need an older installer (and some luck on the repos) or someone's older package directory and installer. All recent installers only go back one release which won't be enough to get you back in line with Clion's requirement.
Might also be worth reaching out to Clion and asking them when support for the recent versions is coming out.

How to build and install GCC on Windows 7, ver. 4.8.1

I would like to upgrade my old GCC compiler to v. 4.8.1.
Currently I'm using Code::Blocks IDE (nightly build, svn 8982), and my compiler is GCC 4.4.1.
I downloaded fresh GCC from their site - gcc.gnu.org
From what I've read in documentation, they say that I should first build compiler by myself. Afterwards, they throw something like this:
% mkdir objdir
% cd objdir
% srcdir/configure [options] [target]
However, I completly have no idea what to do with these lines.
And even if I did, afterwards come maaany lines with some additional options, where I am even more lost then before.
I don't know if there is any easy way of installing it, but from what I've read here, I can download MSYS from MinGW and it will do everything(I hope?) for me. However, from what I see there, it says that MinGW comes with already built version of GCC, meaning I won't be able to use mine anyway. Am I right? If yes, what should I do to build and use GCC? If not, then will I be able to easily install GCC after downloading MSYS?
Thanks in advance.
I can download MSYS from MinGW
YOu can.
and it will do everything(I hope?) for me.
It won't. MSys provides environment for building software that requires unix-like environment. To be more precise - autotools. If you aren't familiar with *nix build process (configure script), Mingw won't really help you.
However, from what I see there, it says that MinGW comes with already built version of GCC,
Yes, version 4.7.2 at the moment.
meaning I won't be able to use mine anyway. Am I right?
No. If you don't add Mingw/MSys to your PATH, you can keep multiple different installations on the same machine. It also SHOULD be possible to use multiple different versions of gcc within the same installation of mingw, but things can get messy here. (gcc3 and gcc4 should be able to exist, not sure about 4.7.2 and 4.8.1)
If yes, what should I do to build and use GCC?
You should search for precompiled binaries provided by somebody else. Compiling gcc yourself is possible, but for you (i.e. if you aren't arleady familiar with msys) it might not be worth the effort.
Either you could try http://mingw-w64.sourceforge.net/ or mingw-nuwen. Mingw provided by nuwen is 32bit only, but is very easy to install. The problem is that standard mingw distribution includes update tool (with "mingw uppdate" and "mingw upgrade" you can upgrade installed packages to their latest version), bug "mingw-nuwen" doesn't have such tool.
Because you say
However, I completly have no idea what to do with these lines.
You should either use precompiled mingw provded by somebody else, or use another compiler. If you don't really need bleeding-edge C++11 support ON WINDOWS, use visual studio express.

How to update GCC in MinGW on Windows?

I'm used to manually install GCC from source before on Ubuntu and it was a painful process. So I really don't want to do repeat this process. Currently, I have MinGW and GCC (4.6.2) installed on my machine. So is there an easy way to update GCC without building it entirely from source? Has anyone done it before can share me some tips?
Update using terminal:
Run the command prompt/terminal (cmd or sh).
Update the package list:
mingw-get update
After updating the package list, run:
mingw-get upgrade
When the command finishes running, all of your packages will be upgraded.
Update using the GUI version:
If you aren't used to the terminal, there is also a GUI version of MinGW called "MinGW Installation Manager", which is normally located at:
C:\MinGW\libexec\mingw-get\guimain.exe
When the GUI is open, tap Installation -> Update Catalogue. This will update the package list.
After that, tap Installation -> Mark All Upgrades. This will select all of the packages which can be upgraded.
Finally, tap Installation -> Apply Changes to apply the upgrades.
Snapshots and release builds of the MinGW http://code.google.com/p/mingw-builds/downloads/list
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.
if you use MSYS2
just open mingw64-console and type in:
# Update the package database and core system packages with:
pacman -Syu
# If needed, close MSYS2, run it again from Start menu. Update the rest with:
pacman -Su
I have built a more up to date GCC 4.7 (it's built within code freeze, so it should be equivalent with the release). Also, this build contains <thread> support.
32-bit
64-bit
The -gcc_linux package is what you want if you want to use it on Linux. Just extract somewhere and add the mingw??/bin directory to PATH.
PS: There's a native Windows compiler and a Windows Clang build. I suggest using Clang only with one of my GCC 4.6 builds, as it has trouble with GCC 4.7's libstd++. Extract the Clang package in the same directory as the GCC package and it will work out of the box.
The MinGW-w64 build from http://winlibs.com/ has the latest GCC version and requires no installation, just unzip the download. To upgrade you can just replace the mingw32 or mingw64 folder with the new version.
To get latest MinGW64 in Windows: https://sourceforge.net/projects/mingw-w64/?source=typ_redirect
For all platforms: https://mingw-w64.org/doku.php/download
You just need to update your g++ compiler if its not.
First problem can be solved through this:
Update using the GUI version:
If you aren't used to the terminal, there is also a GUI version of MinGW called "MinGW Installation Manager", which is normally located at:
C:\MinGW\libexec\mingw-get\guimain.exe
When the GUI is open, tap
Installation -> Update Catalogue
. This will update the package list.
After that, tap
Installation -> Mark All Upgrades
. This will select all of the packages which can be upgraded.
Finally, tap
Installation -> Apply Changes
to apply the upgrades.
2nd Problem could be that if you didn't updated the path of mingw in environment variables.