help:developer_tools:cygwin_full_install
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | help:developer_tools:cygwin_full_install [2020/06/20 14:39] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ====== Cygwin GCC - How to Install on Windows ====== | ||
+ | |||
+ | Copied from: https:// | ||
+ | |||
+ | Several modern C++ features are currently missing from Visual Studio Express, and from the system GCC compiler provided with many of today’s Linux distributions. [[http:// | ||
+ | |||
+ | The following guide((Copyright © 2018 [[https:// | ||
+ | |||
+ | The steps are: | ||
+ | |||
+ | - Install Cygwin, which gives us a Unix-like environment running on Windows. | ||
+ | - Install a set of Cygwin packages required for building GCC. | ||
+ | - From within Cygwin, download the GCC source code, build and install it. | ||
+ | - Test the new GCC compiler in C++14 mode using the '' | ||
+ | |||
+ | //[Update: As a commenter points out, you can also install native GCC compilers [[http:// | ||
+ | |||
+ | ===== 1. Install Cygwin ===== | ||
+ | |||
+ | First, download and run either the 32- or 64-bit version of the [[https:// | ||
+ | |||
+ | When you reach the “Select Packages” step (shown below), don’t bother selecting any packages yet. Just go ahead and click Next. We’ll add additional packages from the command line later. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | After the Cygwin installer completes, it’s very important to keep the installer around. The installer is an executable named either '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | If you already have Cygwin installed, it’s a good idea to re-run the installer to make sure it has the latest available packages. Alternatively, | ||
+ | |||
+ | ===== 2. Install Required Cygwin Packages ===== | ||
+ | |||
+ | Next, you’ll need to add several packages to Cygwin. You can add them all in one fell swoop. Just open a Command Prompt (in Windows), navigate to the folder where the Cygwin installer is located, and run the following command: | ||
+ | |||
+ | < | ||
+ | C: | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | A window will pop up and download all the required packages along with their dependencies. | ||
+ | |||
+ | At this point, you now have a working GCC compiler on your system. It’s not the latest version of GCC; it’s whatever version the Cygwin maintainers chose as their system compiler. At the time of writing, that’s GCC 4.8.3. To get a more recent version of GCC, you’ll have to compile it yourself, using the GCC compiler you already have. | ||
+ | |||
+ | ===== 3. Download, Build and Install the Latest GCC ===== | ||
+ | |||
+ | Open a Cygwin terminal, either from the Start menu or by running '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | If your machine is located behind a proxy server, you must run the following command from the Cygwin terminal before proceeding – otherwise, '' | ||
+ | |||
+ | < | ||
+ | export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY | ||
+ | </ | ||
+ | To download and extract the latest GCC source code, enter the following commands in the Cygwin terminal. If you’re following this guide at a later date, there will surely be a [[https:// | ||
+ | |||
+ | < | ||
+ | wget http:// | ||
+ | tar xf gcc-4.9.2.tar.gz | ||
+ | </ | ||
+ | That will create a subdirectory named '' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | The '' | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | mkdir build-gcc | ||
+ | cd build-gcc | ||
+ | ../ | ||
+ | </ | ||
+ | Here’s a description of the command-line options passed to '' | ||
+ | |||
+ | * The '' | ||
+ | * The '' | ||
+ | * The '' | ||
+ | * The '' | ||
+ | * By default, the new version of GCC will be installed to '' | ||
+ | |||
+ | We’re not going to build a new Binutils, which GCC relies on, because the existing Binutils provided by Cygwin is already quite recent. We’re also skipping a couple of packages, namely ISL and CLooG, which means that the new compiler won’t be able to use any of the [[https:// | ||
+ | |||
+ | Next, we’ll actually build the new GCC compiler suite, including C, C++ and the standard C++ library. This is the longest step. | ||
+ | |||
+ | < | ||
+ | make -j4 | ||
+ | </ | ||
+ | The '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Be warned: I encountered a [[http:// | ||
+ | |||
+ | Once that’s finished, install the new compiler: | ||
+ | |||
+ | < | ||
+ | make install | ||
+ | cd .. | ||
+ | </ | ||
+ | This installs several executables to '' | ||
+ | |||
+ | If, later, you decide to uninstall the new GCC compiler, you have several options: | ||
+ | |||
+ | * If you installed GCC to a directory other than '' | ||
+ | * If you installed GCC to '' | ||
+ | * You can simply uninstall Cygwin itself, by deleting the '' | ||
+ | |||
+ | ===== 4. Test the New Compiler ===== | ||
+ | |||
+ | All right, let’s compile some code that uses generic lambdas! Generic lambdas are part of the C++14 standard. They let you pass arguments to lambda functions as '' | ||
+ | |||
+ | <code c++ test.cpp> | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | auto lambda = [](auto x){ return x; }; | ||
+ | std::cout << lambda(" | ||
+ | return 0; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | You can add files to your home directory in Cygwin using any Windows-based text editor; just save them to the folder '' | ||
+ | |||
+ | First, let’s see what happens when we try to compile it using the system GCC compiler provided by Cygwin: | ||
+ | |||
+ | <code bash> | ||
+ | g++ --version | ||
+ | g++ -std=c++1y test.cpp | ||
+ | </ | ||
+ | If the system compiler version is less than 4.9, compilation will fail: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Now, let’s try it again using our freshly built GCC compiler. The new compiler is already configured to locate its include files in '' | ||
+ | |||
+ | <code bash> | ||
+ | g++-4.9.2 -std=c++14 test.cpp | ||
+ | ./a.exe | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | It works! | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
help/developer_tools/cygwin_full_install.txt · Last modified: 2020/06/20 14:39 by 127.0.0.1