Gnu gcc compiler для codeblocks скачать для windows

When you launch Code::Blocks for the first time, it will scan the system for any supported compilers. Once this scan has finished, Code::Blocks will have been correctly configured for any detected compilers. Code::Blocks will also have default configurations even for compilers that were not found.

When you launch Code::Blocks for the first time, it will scan the system for any supported compilers. Once this scan has finished, Code::Blocks will have been correctly configured for any detected compilers. Code::Blocks will also have default configurations even for compilers that were not found.

This article is a guide for obtaining, installing, and configuring the various compilers that Code::Blocks can use.

Compiler-neutral setup steps

Before using a compiler with Code::Blocks you have to install it. The method for installing the compiler depends on the Operating system you’re using, the Compiler you intend to use and so on.
If you installed the compiler on its default installation directory, there is nothing more to configure (if the compiler is natively supported by Code::Blocks). Launch Code::Blocks and you’re all set  :)

  • If that is not the case, launch Code::Blocks. If it is the first time you launch it, the compiler auto-detection will be launched.
  • If your compiler was not auto-detected, go to «Settings->Compiler and Debugger->Global Compiler settings->Toolchain executables», select the compiler you installed and press «Auto-detect».
  • If you get a message saying that the compiler was auto-detected, congratulations!
  • If not, then press the button with the three dots next to the «Auto-detect» button and select the installation directory of your compiler manually.

NOTE: The compiler’s installation directory is exactly this: the installation directory. Not the «bin» subdirectory nor any other.

Windows

Once you’ve installed a new compiler, be sure to read the Compiler-neutral setup steps at the end of this article.

At the time of this writing, Code::Blocks supports the following compilers in Windows:

  • MinGW GCC C/C++ Free Compiler, including GFortran
    • Cygwin GCC C/C++ Free Compiler
      • HOWTO: Use Cygwin 1.7 with Code::Blocks
  • MSP430 GCC C/C++
  • TriCore GCC C/C++
  • PowerPC GCC C/C++
  • Small Device Free C Compiler (SDCC)
  • Digital Mars Free C/C++ Compiler
  • Digital Mars D Compiler for Windows

These compilers are generally still under active development by their publishers, so a new version of their software could be released that is incompatible with the current version of Code::Blocks.

The following compilers are still supported by Code::Blocks, but are no longer available from their original publishers.

  • Microsoft’s Visual C++ 2003 — 2010
  • Borland’s C/C++ Free Compiler 5.5

The following publishers have released newer versions of their compilers which should be tested against the current configuration. In other words, it is not known yet whether these compilers still work with Code::Blocks.

  • OpenWatcom Free C/C++ Compiler
  • Intel C/C++ Compiler

MinGW/GCC

The official MinGW website is at mingw.org. A MinGW-bundled version of the latest Code::Blocks release is available from the Code::Blocks download page. If you install this version, the GCC compiler will be automatically detected and set as the default. Also you can use the TDM’s GCC/mingw32 Builds from [1] or [2].

Note: In any case, if you don’t install MinGW in C:MinGW, you’ll need to update the configuration of GCC in Code::Blocks.

Official MinGW.org

You can install MinGW yourself, by using an automatic downloader/installer or by downloading and unpacking the required packages by hand from mingw.org, here: [3].

Packages required (suggested) for MinGW/GCC v3.4.5:

  • Compiler:
    • gcc-build-3.4.5-20060117-3.tar.gz
    • gcc-core-3.4.5-20060117-3.tar.gz
    • gcc-g++-3.4.5-20060117-3.tar.gz
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

Packages required (suggested) for MinGW/GCC v4.4.0:

  • Compiler:
    • gcc-full-4.4.0-mingw32-bin-2.tar.lzma
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

HOWTO: Use Cygwin 1.7 with Code::Blocks

Cygwin 1.7 changed the way symlinks were created and handled when invoked from a command prompt. I couldn’t find a way to force CB to use a unix-link shell, but was able to find a work around when perusing the Cygwin mailing lists.

The symptom would show up with a message similar to the one below:

 Execution of 'g++.exe -Wall -fexceptions  -g     -c c:/dev/code/cb1/main.cpp -o obj/Debug/main.o' in 'c:devcodecb1' failed.

Executing the same command from the CMD.EXE prompt yields an «Access is denied» message. This was how I was able to track down why the issue occurred. For more info, see this cygwin mailing list thread: http://www.mail-archive.com/cygwin@cygwin.com/msg104088.html

Solution

The solution is to point your compiler and linker directly to the version of gcc and g++ that you want to use.

In my case, I wanted to use gcc-4.exe and g++-4.exe and so, I went into Settings->Compiler and Debugger->Toolchain executables. There I changed the «C Complier», «C++ Compiler» and «Linker for dynamic libs» to point to gcc-4.exe, g++-4.exe and g++-4.exe.

After this, compilation and linking worked fine.

It would also be a good idea to add an environment variable CYGWIN with a value of nodosfilewarning in Settings->Environment->Environment Variables. This eliminates the following (harmless) warning message:

 MS-DOS style path detected: c:/
   Preferred POSIX equivalent is: /c
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
     http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

See also: Installing Cygwin Compiler

(Unofficial) TDM — «Twilight Dragon Media»

These packages are called TDM’s GCC/mingw32 Builds and can be obtained from [/index.php/topic,10508.0.html] or [4].

Packages required (suggested) for TDM’s GCC/mingw32 Builds v4.4.1-tdm-2 SJLJ:
…which can be found here: [5] under: TDM-GCC 4.4 series -> 4.4.1-tdm-2 SJLJ.

  • Compiler:
    • gcc-4.4.1-tdm-2-core.zip
    • gcc-4.4.1-tdm-2-g++.zip
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326-3.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

These packages are included in both the Bundled Installer and the On-Demand Installer available via TDMs page referenced above for users who do not wish to download and install them manually.

Embarcadero C++ Compiler BCC32C

Formerly Borland’s C++ Compiler, this compiler is now published by Embarcadero, with active on-going development; the current version is 10.1 as of this writing. Go to their product download page to download. You will be asked to enter some registration information (registration is free) then the download will begin. You will receive a ZIP archive which contains installation instructions in a text file in the root directory of the archive; it does not have an installer program.

Digital Mars C/C++ Free Compiler

Go to DigitalMars. Accept the license agreement and you’ll be redirected to a page containing download links.

In that page, download:

  • The Digital Mars C/C++ Compiler (dm8**c.zip)
  • The Basic Utilities (bup.zip)
  • The STLport library (stlport.zip)

Open dmbinsc.ini in a text editor, and replace the line

INCLUDE="%@P%..include";"%@P%..mfcinclude";%INCLUDE%

with

INCLUDE="%@P%..stlportstlport";"%@P%..include";"%@P%..mfcinclude";%INCLUDE%

Intel C++ Compiler

Please note that on Windows platform, Intel C/C++ compiler requires Microsoft Visual C++[6] to be present in your system in order to function properly. It will not compile any C++ program without it. You should also note that Windows SDK[7] shall be installed in order to compile Windows app.

Code::Blocks (C::B) is now able to detect (from svn revision 4967 onwards) Intel C/C++ compiler and it’ll then automatically setup the MSVC compiler so that the Intel compiler works as intended. However if you wish to manually install the Intel C/C++ compiler, then follow the following steps.

  • Go to Settings > Compilers and debuggers and then select Intel C/C++ compiler.
  • Click on the Toolchain executables tab. Point to the installation directory, e.g. C:Program FilesIntelCompilerC++10.1.020IA32 , inside the Compiler’s installation directory textbox.
  • Click on the Additional Paths tab and fill in the directories pointing to MSVC bin directory and the Windows SDK directory. It may look like-
C:Program FilesMicrosoft Visual Studio 8VCbin
C:Program FilesMicrosoft Visual Studio 8Common7IDE
C:Program FilesMicrosoft SDKsWindowsv6.0bin
  • Click on the Search directories tab and add the include directories containing headers offered by Intel C/C++ compiler, MSVC compiler and the Windows SDK headers to Compiler and Resource compiler. It may look like-
C:Program FilesIntelCompilerC++10.1.020IA32include
C:Program FilesMicrosoft Visual Studio 8VCinclude
C:Program FilesMicrosoft SDKsWindowsv6.0Include
  • Click on the Linker tab under Search directories tab and add the directories containing libraries offered by Intel C/C++ compiler, MSVC compiler and the Windows SDK. It may look like-
C:Program FilesIntelCompilerC++10.1.020IA32lib
C:Program FilesMicrosoft Visual Studio 8VClib
C:Program FilesMicrosoft SDKsWindowsv6.0Lib

Click on the OK button to save the settings. Now you should be able to use Intel C/C++ compilers on Windows with C::B.

Note: The directories specified above may be different on your PC.

Digital Mars D Compiler for Windows

Now Digital Mars D Compiler (DMD) supports 32bit Windows, and in future it will support 64bit Windows.
If you want to build D program in CodeBlocks on 32bit Windows, please following the instructions as bellow.

1). Install DMD(2.0) into your Windows system.

You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website.
DMD for Windows http://www.digitalmars.com/d/2.0/dmd-windows.html

The newest DMD2 source you can get here: https://github.com/D-Programming-Language

2). Settings in CodeBlocks.

You should add correct DMD pathes into CodeBlocks Global compiler settings

   2.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   2.2). click "Compiler settings -> Other options", add  -m32  into the field;
   2.3). click "Linker settings", and add "D:ProgramDMD2windowslibphobos.lib" into the "Link libraries";
   2.4). click "Search directories -> Compiler", and add "D:ProgramDMD2srcphobos" into the field;
   2.5). click "Search directories -> Linker", and add "D:ProgramDMD2windowslib" into the field;
   2.6). click "Toolchain executables", add "D:ProgramDMD2windows" into the "Compiler's installation directory" filed;
         (if you installed DMD2 correctly acc. to Installation setp, just click 'Auto-detect' button.)
   2.7). Additional: If you wan to specify the DMC (Digital Mars C/C++ Compiler) you can do like this:
         click "Toolchain executables -> Additional Paths", and add "D:ProgramDMCbin" into the field.

The «D:ProgramDMD2» or «D:ProgramDMCbin» here should change to your own DMD or DMC path in your system.

3). Testing D program in CodeBlocks.

In CodeBlocks, produce a D Application project, and input your own D code into the .d file in the project, then build/run.

Linux

At the time of this writing, Code::Blocks supports the following compilers in Linux:

  • GNU GCC C/C++ Free Compiler
  • Small Device Free C Compiler (SDCC)
  • Intel C/C++ Compiler
  • Digital Mars D Compiler for Linux

Digital Mars D Compiler for Linux

Now Digital Mars D Compiler (DMD) supports 32bit and 64bit Linux, and ‘support Linux library’ is under construction. If you want to build D program in CodeBlocks on 32bit and 64bit Linux, please following the instructions as bellow.

1). Install DMD(2.0) into your Linux system.

You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website.
DMD for Linux http://www.digitalmars.com/d/2.0/dmd-linux.html

The newest DMD2 source you can get here:
https://github.com/D-Programming-Language

2). Settings in CodeBlocks.

A). 32bit Linux & 32bit DMD2.

On 32bit Linux, you should combine 32bit DMD2 from DMD2 source and install it into your system.

You should add correct DMD pathes into CodeBlocks Global compiler settings.

   A.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   A.2). click "Compiler settings -> Other options", add  -m32  into the field.
   A.3). click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries". 
   A.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   A.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field. 
   A.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   A.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m32 -lrt" or "gcc -lrt".

If you installed DMD2 to a different path, please modify «/opt/dmd2» to your own DMD2 path.

B1). 64bit Linux & 64bit DMD2.

On 64bit Linux, you can combine 64bit DMD2 from DMD2 source and install it into your system.

You should add correct DMD paths into CodeBlocks Global compiler settings.

   B1.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   B1.2). click "Compiler settings -> Other options", add  -m64  into the field.
   B1.3). click "Linker settings", and add "/opt/dmd2/linux/lib64/libphobos2.a" into the "Link libraries". 
   B1.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   B1.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib64" into the field. 
   B1.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   B1.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m64 -lrt" or "gcc -lrt".

If you installed DMD2 to a different path, please modify «/opt/dmd2» to your own DMD2 path.

B2). 64bit Linux with 32bit DMD2.

On 64bit Linux, you can combine 32bit DMD2 with 64bit together from DMD2 source and install them into your system.

You should add correct DMD paths into CodeBlocks Global compiler settings.

   B2.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   B2.2). click "Compiler settings -> Other options", add -m32 into the field.
   B2.3). click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries". 
   B2.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   B2.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field. 
   B2.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   B2.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m32 -lrt".

If you installed DMD2 to a different path, please modify «/opt/dmd2» to your own DMD2 path.

3). Testing D program in CodeBlocks.

In CodeBlocks, produce a D Application project, and input your own D code into the .d file in the project, then build/run.

Downloading the GNU GCC compiler & GDB debugger

Under Linux you’ll, most probably, already have everything that is needed in order to compile. All major Linux distributions (RedHat, Debian, SuSE, Mandriva, Gentoo, ArchLinux, etc) come with GCC & GDB preinstalled. To make sure you have have gcc installed, go to your terminal and type ‘gcc -v’. In case you have GCC installed, you will get GCC’s compile options and version number.

Mac OS X

The Mac OS X port efforts has began recently, but it should be a matter of time until these compilers will be supported:

  • GNU GCC
  • Intel Compiler beta (not yet released to public)
  • Small Device C Compiler (SDCC)

Downloading the GNU GCC compiler & GDB debugger

Under Mac you’ll need to install a compatible version Xcode Tools from http://developer.apple.com/tools/ (or http://developer.apple.com/downloads). You need the «Command Line Tools».

This will install Apple versions of:

http://www.gnu.org/software/gcc/

http://www.gnu.org/software/gdb/

http://www.gnu.org/software/make/

Setting up compiler switches

Usually you need to tweak the compiler options to be able to compile C++ applications — that’s the stuff Xcode hides from your eyes, but you better should know. You need to point to the GNU compiler’s C/C++ include folders, to the GNU linkers libraries folder and a adjust the compiler options to setup the GNU compiler root path. Those path’s differ depending on what hardware (processor architecture) and what version of MacOS is used. For an Intel based Mac with MacOS 10.6.2 and Xcode v3.2.2 the following should work:

Compiler search directories («include» folders):


/Developer/SDKs/MacOSX10.6.sdk/usr/include


/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1

Linker search directories («library» folders):


/Developer/SDKs/MacOSX10.6.sdk/usr/lib


/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1

Additional compiler flags:


-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -gdwarf-2

Remote Compilation

Remote compilation is not directly supported by Code::Blocks, however, the following articles explain two remote compilation systems, which use 3rd party programs to provide this functionality:

Installing Uniwin remote compiler
Using Xming for remote compilation

Misc. Custom Compilers

There are several user contributions for different (non-C/C++) compiler which are listed here:

https://wiki.codeblocks.org/index.php?title=User_documentation#Compilers

In this tutorial, we will learn how to install GCC in Windows 10, Mac, and Linux.

We will use an open-source Integrated Development environment named Code::Blocks which bundles a compiler (named gcc offered by Free Software Foundation GNU), editor and debugger in a neat package.

Step 1) Download Binary release

Go to http://www.codeblocks.org/downloads and click Binary Release.

How to Install GCC on Windows

Step 2) Select the installer with GCC for Windows compiler

Choose the installer with GCC Compiler, e.g., codeblocks-17.12mingw-setup.exe which includes MinGW’s GNU GCC compiler download and GNU GDB debugger with Code::Blocks source files.

How to Install GCC on Windows

Step 3) Start installation

Run the downloaded installer and accept the default options to install GCC Windows file.

How to Install GCC on Windows

Step 4) Accept the terms and conditions

Accept the Agreement

How to Install GCC on Windows

Step 5) Keep default component selection

Keep the component selection default and click Next.

How to Install GCC on Windows

Step 6) Locate the installation path

You may change the installation folder and click Next.

How to Install GCC on Windows

Step 7) Find and double-click on the CodeBlocks icon

To launch Code::Blocks double click on the icon.

How to Install GCC on Windows

Step 8) Let it detect the compiler itself

It will detect the GCC compiler for Windows automatically, set it as default.

How to Install GCC on Windows

Associate C/C++ files with code::blocks

Step 9) Open the IDE and start using

You will see the IDE Home screen.

How to Install GCC on Windows

Install GCC Linux

Linux operating systems mostly comes with GCC preinstalled. To verify if the compiler is installed on the machine, run the following command in the terminal:

gcc --version

After executing this command if the gcc is installed on the machine then it will return the information about the compiler otherwise it will ask you to install the compiler.

To set up the ‘C’ environment on Linux distributions follow the given steps:

1. Open terminal.

2. For red-hat, Fedora users, type and execute this command

# yum groupinstall 'Development Tools'

3. For Debian and Ubuntu users, type and execute following command

$ sudo apt-get update
$ sudo apt-get install build-essential manpages-dev

4. To verify that the GCC has been successfully installed on the machine as we discussed earlier, execute the following command

gcc --version

Install GCC on Mac

To set up a ‘C’ programming environment on MAC operating system, follow the given steps:

1. Visit the given link https://developer.apple.com/downloads/index.action and download. You will need an Apple developer ID

“Command Line Tools for X-Code,” pick any version (latest version is always recommended) and download the .dmg file.

2. After the file is being downloaded on the machine, double click and follow the wizard and install the file. Always keep the default settings as suggested by the installation wizard.

3. After the installation process, open a terminal and run gcc -v command to check if everything is successfully installed.

Conclusion:

‘C‘ program can be written and executed on any machine that has a suitable environment to run the program. Its recommended using an IDE or C compiler for Windows to run C programs. An IDE includes a compiler, editor and debugger. Clanfg, MinGW compiler (Minimalist GNU compiler collection for Windows), Portable ‘C’ compiler, Turbo C are popular compilers available.

Download

GCC releases may be downloaded from our
mirror sites.

Important: these are source releases, so will be of little
use if you do not already have a C++ compiler installed.

As one option, there are
pre-compiled
binaries. for various platforms.

You can also retrieve our sources using Git.

GCC Timeline

The table is sorted by date. Please refer to our
development plan for future
releases and an alternative view of the release history.

Release Release date
GCC 12.2 August 19, 2022
GCC 10.4 June 28, 2022
GCC 9.5 May 27, 2022
GCC 12.1 May 6, 2022
GCC 11.3 April 21, 2022
GCC 11.2 July 28, 2021
GCC 9.4 June 1, 2021
GCC 8.5 May 14, 2021
GCC 11.1 April 27, 2021
GCC 10.3 April 8, 2021
GCC 10.2 July 23, 2020
GCC 10.1 May 7, 2020
GCC 9.3 March 12, 2020
GCC 8.4 March 4, 2020
GCC 7.5 November 14, 2019
GCC 9.2 August 12, 2019
GCC 9.1 May 3, 2019
GCC 8.3 February 22, 2019
GCC 7.4 December 6, 2018
GCC 6.5 October 26, 2018
GCC 8.2 July 26, 2018
GCC 8.1 May 2, 2018
GCC 7.3 January 25, 2018
GCC 5.5 October 10, 2017
GCC 7.2 August 14, 2017
GCC 6.4 July 4, 2017
GCC 7.1 May 2, 2017
GCC 6.3 December 21, 2016
GCC 6.2 August 22, 2016
GCC 4.9.4 August 3, 2016
GCC 5.4 June 3, 2016
GCC 6.1 April 27, 2016
GCC 5.3 December 4, 2015
GCC 5.2 July 16, 2015
GCC 4.9.3 June 26, 2015
GCC 4.8.5 June 23, 2015
GCC 5.1 April 22, 2015
GCC 4.8.4 December 19, 2014
GCC 4.9.2 October 30, 2014
GCC 4.9.1 July 16, 2014
GCC 4.7.4 June 12, 2014
GCC 4.8.3 May 22, 2014
GCC 4.9.0 April 22, 2014
GCC 4.8.2 October 16, 2013
GCC 4.8.1 May 31, 2013
GCC 4.6.4 April 12, 2013
GCC 4.7.3 April 11, 2013
GCC 4.8.0 March 22, 2013
GCC 4.7.2 September 20, 2012
GCC 4.5.4 July 2, 2012
GCC 4.7.1 June 14, 2012
GCC 4.7.0 March 22, 2012
GCC 4.4.7 March 13, 2012
GCC 4.6.3 March 1, 2012
GCC 4.6.2 October 26, 2011
GCC 4.6.1 June 27, 2011
GCC 4.3.6 June 27, 2011
GCC 4.5.3 April 28, 2011
GCC 4.4.6 April 16, 2011
GCC 4.6.0 March 25, 2011
GCC 4.5.2 December 16, 2010
GCC 4.4.5 October 1, 2010
GCC 4.5.1 July 31, 2010
GCC 4.3.5 May 22, 2010
GCC 4.4.4 April 29, 2010
GCC 4.5.0 April 14, 2010
GCC 4.4.3 January 21, 2010
GCC 4.4.2 October 15, 2009
GCC 4.3.4 August 4, 2009
GCC 4.4.1 July 22, 2009
GCC 4.4.0 April 21, 2009
GCC 4.3.3 January 24, 2009
GCC 4.3.2 August 27, 2008
GCC 4.3.1 June 6, 2008
GCC 4.2.4 May 19, 2008
GCC 4.3.0 March 5, 2008
GCC 4.2.3 February 1, 2008
GCC 4.2.2 October 7, 2007
GCC 4.2.1 July 18, 2007
GCC 4.2.0 May 13, 2007
GCC 4.1.2 February 13, 2007
GCC 4.0.4 January 31, 2007
GCC 4.1.1 May 24, 2006
GCC 4.0.3 March 10, 2006
GCC 3.4.6 March 06, 2006
GCC 4.1.0 February 28, 2006
GCC 3.4.5 November 30, 2005
GCC 4.0.2 September 28, 2005
GCC 4.0.1 July 7, 2005
GCC 3.4.4 May 18, 2005
GCC 3.3.6 May 3, 2005
GCC 4.0.0 April 20, 2005
GCC 3.4.3 November 4, 2004
GCC 3.3.5 September 30, 2004
GCC 3.4.2 September 6, 2004
GCC 3.4.1 July 1, 2004
GCC 3.3.4 May 31, 2004
GCC 3.4.0 April 18, 2004
GCC 3.3.3 February 14, 2004
GCC 3.3.2 October 17, 2003
GCC 3.3.1 August 8, 2003
GCC 3.3 May 13, 2003
GCC 3.2.3 April 22, 2003
GCC 3.2.2 February 05, 2003
GCC 3.2.1 November 19, 2002
GCC 3.2 August 14, 2002
GCC 3.1.1 July 25, 2002
GCC 3.1 May 15, 2002
GCC 3.0.4 February 20, 2002
GCC 3.0.3 December 20, 2001
GCC 3.0.2 October 25, 2001
GCC 3.0.1 August 20, 2001
GCC 3.0 June 18, 2001
GCC 2.95.3 March 16, 2001
GCC 2.95.2 October 24, 1999
GCC 2.95.1 August 19, 1999
GCC 2.95 July 31, 1999
EGCS 1.1.2 March 15, 1999
EGCS 1.1.1 December 1, 1998
EGCS 1.1 September 3, 1998
EGCS 1.0.3 May 15, 1998
EGCS 1.0.2 March 16, 1998
gcc 2.8.1 March 2, 1998
gcc 2.8.0 January 7, 1998
EGCS 1.0.1 January 6, 1998
EGCS 1.0 December 3, 1997
2.7.2.3 August 22, 1997
2.7.2.2 January 29, 1997
2.7.2.1 June 29, 1996
2.7.2 November 26, 1995
2.7.1 November 12, 1995
2.7.0 June 16, 1995
2.6.3 November 30, 1994
2.6.2 November 12, 1994
2.6.1 November 1, 1994
2.6.0 July 14, 1994
2.5.8 January 24, 1994
2.5.7 December 12, 1993
2.5.6 December 3, 1993
2.5.5 November 27, 1993
2.5.4 November 16, 1993
2.5.3 November 11, 1993
2.5.2 November 1, 1993
2.5.1 October 31, 1993
2.5.0 October 22, 1993
2.4.5 June 20, 1993
2.4.4 June 19, 1993
2.4.3 June 1, 1993
2.4.2 May 31, 1993
2.4.1 May 26, 1993
2.4.0 May 17, 1993
2.3.3 December 26, 1992
2.3.2 November 27, 1992
2.3.1 November 1, 1992
2.3 October 31, 1992
2.2.2 June 14, 1992
2.2.1 June 9, 1992
2.2 June 8, 1992
2.1 March 24, 1992
2.0 February 22, 1992
1.42.0 (g++) September 20, 1992
1.42 September 20, 1992
1.41 August 27, 1992
1.41.0 (g++) July 13, 1992
1.40.3 (g++) October 19, 1991
1.40 June 1, 1991
1.39.1 (g++) May 4, 1991
1.39 January 16, 1991
1.38 December 21, 1990
1.37.1 (g++) March 1, 1990
1.37.0 (g++) February 28, 1990
1.37.1 February 21, 1990
1.37 February 11, 1990
1.36.4 (g++) January 30, 1990
1.36.3 (g++) January 16, 1990
1.36 September 24, 1989
1.35 April 26, 1989
1.34 February 23, 1989
1.33 February 1, 1989
1.32 December 21, 1988
1.31 November 19, 1988
1.30 October 13, 1988
1.29 October 6, 1988
1.28 September 14, 1988
1.27 September 5, 1988
1.26 August 18, 1988
1.25 August 3, 1988
1.24 July 2, 1988
1.23 June 26, 1988
1.22 May 22, 1988
1.21 May 1, 1988
1.20 April 19, 1988
1.19 March 29, 1988
1.18 February 4, 1988
1.17 January 9, 1988
1.16 December 19, 1987
1.15.3 (g++) December 18, 1987
1.15 November 28, 1987
1.14 November 6, 1987
1.13 October 12, 1987
1.12 October 3, 1987
1.11 September 5, 1987 (announced late)
1.10 August 22, 1987
1.9 August 18, 1987 (never announced)
1.8 August 10, 1987
1.7 July 21, 1987
1.6 July 2, 1987
1.5 June 18, 1987
1.4 June 13, 1987
1.3 June 10, 1987
1.2 June 1, 1987
1.1 May 24, 1987
1.0 May 23, 1987
0.9 (first beta release) March 22, 1987

Overview

Compilers are used to convert the source code into machine-readable code so that the computer can understand it. For every programming language, we have to set up a compiler.

In C language, there are two ways to set up a compiler. The first one is installing the C/GCC compiler manually, and the second is installing Code::Blocks or any IDE(Integrated Development Environment) and within that, including the GCC compiler during installation.

After installing the compiler, we need to set its path to environment path variables because it allows the C program to compile from any directory on your computer.

Before reading this article, read these C Programming articles:

  • History of C Language
  • Importance of C Programming Language

Scope

  • The article explains the step-by-step installation of the C/GCC compiler for Windows.
  • The article gives an idea about the different types of source code editors used by the developers and the download link.
  • The article also explains the installation of Code::Blocks IDE with MinGW, a C compiler, and a step-by-step guide to setting the path of the compiler to the environment path variable.

Source Code Editors

The source code editor is a text editor tool designed specially to edit or write the source code of any programming language. There is a basic source code editor present in Windows, i.e., Notepad, but it has limited features; therefore, for better formatting and features like multiple tabs, and plugins, you can use other editors like:

  1. TextPad (for Windows only): It is a powerful, general-purpose editor for plain text files. We can easily type the C program in TextPad.
    You can open Project folders inside the textpad so that you don’t have to open files again and again, like in notepad.

  2. Notepad++ (for Windows only): It is a text editor for Microsoft Windows. Unlike notepad, it supports multiple tabs.

  3. VS Code: (for Windows, Mac, and Linux) Visual Studio Code gives you suggestions to auto-complete the words. It has an inbuilt debugger to trace each line of code.

  4. ATOM: (for Windows, Mac, and Linux): Atom helps you write code faster with a smart and flexible autocomplete.

  5. Sublime Text: Sublime text is a free source code editor with expandable functionality using plugins. It supports almost all programming languages, is community-built, and is maintained under a free license.

Installing C/GCC Compiler for Windows

C/GCC Compiler

Following are the steps to download and install the MinGW GCC Compiler for windows.

Step 1: Search MinGW C Compiler on the Web
To download the MinGW compiler, go to your favorite browser and search MinGW C Compiler or click on the sourceforge.net link.

Search MinGW C Compiler

Step 2: Download MinGW.
After clicking on the green-colored download button on the website, the MinGW setup file will start downloading.

Download MinGW C Compiler

Step 3: Locate the MinGW-get-setup.exe File and Start Installation.

Locate the setup.exe file on your Downloads folder and double-click on it.

Locate MinGW C Setup

After double-clicking on the setup file, MinGW Installation Manager Setup Tool will now open. It will show the information like version, name, etc. Click on the Install button and proceed to start the installation.

Install MinGW C

Step 4: Specify Installation Preferences.
Now the installation manager will ask you to specify the installation preferences. For that, you will be asked to choose the installation directory. If you wish to change it, you can browse the explorer and specify the location as per your requirement. After that, click on continue to proceed further.

It is recommended to install it in the default location

MinGW C Installation

Step 5: Download and Set up MinGW Installation Manager.
The installer will now automatically download the required files for MinGW to install on your Windows system. Grab a cup of coffee and wait patiently till the installation manager finishes downloading all the files. When it is done, click on continue to proceed ahead.

Note: Active internet is required throughout the installation process.

Download and setup MinGW

Step 6: Select Packages Required for the Compiler.
There are three packages required for the basic MinGW setup that you have to choose from the MinGW Installation Manager.

1. MinGW32-base Package.
First, you have to install the MinGW32-base package. This package is used to compile the C program, including linker and other binary tools. Right-click on the MinGW32-base option and select Mark for Installation.

MinGW32-base Package

2. MinGW32-gcc-g++ Package.
Now you have to install the MinGW32-gcc-g++ package. This package is used to compile C++ source code. This is an optional component of the MinGW Compiler. It is only required if you are going to program in C++ language only. To select the MinGW32-gcc-g++ right-click on it and select Mark for Installation.

MinGW32-gcc Package

3. MinGW32-gcc-objc package.
At last, you have to install the MinGW32-gcc-objc package. This package is used to compile objective C language. It is an optional component. It is only required if you are going to program in objective C. To select the MinGW32-gcc-objc package, right-click on it and select Mark for Installation.

MinGW32-gcc-objc package

Step 7: Apply the Changes
After selecting all the required packages, go to Installation>>Apply Changes and click on Apply Changes.

Apply changes to MinGW

Step 8: Download the Changes.
Now it is time to download all the packages you selected in the previous step. Click on Apply and proceed further to download and install them.

Download changes to MinGW

The download for the packages will now begin, as shown in the window below. Wait for a few minutes until the download completes.

Download Packages for MinGW

Step 9: Installation Completed.
Now the installation has been completed, click on Close to close the Installation manager.

MinGW Installation Complete

Now the installation of MinGW is finished. To check if it is installed or not, open Command Prompt and type g++ —version.

Installing MinGW Complete

Currently, the command prompt cannot detect the MinGW compiler (GCC) because the environment path variable has not been set. The environment path variable helps to detect the compiler in your whole system. It makes the alias name for the compiler, which denotes the path. Follow the steps below to set the environment path variable for MinGW on the Windows system.

Setting up Path Variable

To set up the path for the C compiler for windows, follows the below steps :
Step 1: Copy the path of the MinGW bin.
When you install the MinGW, it creates a folder named MinGW in C: Drive.
To set the compiler’s path, we need the path to the bin directory of MinGW. So, first,

  • Go to C:>MinGW>bin.
  • Now, inside the bin folder, click on the address bar and copy the address.
  • We require this address to be set as the path in the environment variable.
  • If your install location was somewhere else, you may go to that location where you have installed MinGW.

Setup path variable for C compiler

Note: If you open command prompt directly in the bin path, the g++ —version command will work properly, but the command should work on all the directories in the computer. That is the main reason to set the environment path variable.

Step 2: Open Edit System Variables.
Navigate to the search bar and type Edit the system environment variables and click on open to continue to edit system environment variables.

Edit System Variable for C

Step 3: Edit the Path.
In the User variables for the User section, select the path and click on the Edit button.

Edit the Path for C

Step 4: Setup a New Path.

  • After clicking on the Edit button, a new window, Edit environment variable will open. This window allows us to add the path as per our requirements.
  • Since we want to add a new path, click on the New button. A new window, Edit environment variable, will open. This window allows us to add the path as per our requirements. Click on the ‘ New ‘ button since we want to add a new path.

Set up new Path for C

Step 5: Paste the Path.
Paste the path of the MinGW bin that was copied earlier and click on Ok.

Paste Path

Creating and Running a C program

Step 1: Hello World in C.
To execute a C program, create a text file in any directory of your choice.

Create a Hello World Program in C

Step 2: Type the C code and Save the file.
Type the code in the notepad and save the file with the .c extension. Here we write a program to print hello world to demonstrate this step and save the file as Hello.c.

Type Code for C Program

Step 3: Open Command Prompt.
Now, click on the address bar in the C program’s directory, type cmd, and press Enter.

Open Command Prompt

Step 4: Compile the C program.
To compile the Hello World code that we wrote earlier, type gcc Hello.c (or the name by which you will save the program) and press enter. Writing gcc will invoke the C compiler for windows.

Compile the C Program

Step 5: Compilation completed.
The compiled file will be saved in the same directory with the name a (the name can be different for you).
The type of the file will be Application.

Compilation complete for C program

Step 6: Running the C Program.
To run the compiled file, write the name of the compiled file, i.e., a, as shown in the screenshot below.
Finally, the output will be printed in the command prompt.

Run the C Program

There are alternate methods to install C Compilers. One of them is by installing Code::Blocks IDE.

Let’s see the step-by-step process to install Code::Blocks IDE with C Compiler.

Alternate Method:

Installation using CodeBlocks IDE Binary release

Code::Blocks
Code::Blocks is a C/C++ IDE. It comes with plugins which are external additions to any software for customization. Any kind of functionality can be added by installing a plugin. Plugins like debugger, text formatter, etc. can be added to the IDE.

Below are the steps to download and install the Code::Blocks IDE.

Step 1: Go to Code::Blocks Website.
The first step is to install the Code blocks IDE. Go to any of the browsers and open codeblocks.org. The below web page will appear on your screen. On its left side, click on the Downloads.

CodeBlocks Website

Step 2: Choose the way to download.
After clicking on the downloads on the download’s page, it will redirect you to the next page. Here click on the

Download the binary release, as we will use binary release for this tutorial.

Download the Binary Release

Step 3: Choose the version for download
In the Windows section, click on the codeblocks-20.03mingw-setup.exe (for the 64-bit version).

The codeblocks-20.03mingw-setup.exe comes with the MinGW, including the GCC/G++/GFortan compiler and GDB debugger.

To download the 32-bit version, choose the codeblocks-20.03mingw-32bit-setup.exe

Download the file from the link in front of the selected version, as highlighted in the screenshot below.

Download the Preferred Version

Step 4: Start the installation
Now, the installation file has been downloaded. Double-click on the file and the setup window will appear on the screen. Click on the Next> button and proceed further.

Start Code Block Installation

Step 5: Accept the License Agreement
The license agreement for terms and conditions will appear on the screen. Read the license agreement, click on the I Agree button, and proceed further.

License Agreement for Code Blocks

Step 6: Choose Components.
In this step, check whether all the checkboxes are checked or not. For smooth installation, all components should be selected. After that, click on Next to continue.

Code Blocks Components

Step 7: Choose the install location and start installing.
Choose the location on the drive where the application is to be installed. It automatically takes the C: Drive location. To change it, click on browse, choose the location, and click on Next to proceed further.

Start Code Blocks Instllation

The installer will start to extract the files on the destination folder you chose in the previous step, and installation will begin.

Extract Files in Folder

Step 8: Installation complete.
The installation is completed successfully. Once the installation is finished, a pop message saying — Do you want to run Code::Blocks now? Will appear. You may click on the Yes button to start the Code::Blocks IDE.

Now make sure the IDE detects the C compiler for Windows. To do that, follow the steps below.

Complete Codeblocks Installation

Step 9: Setting up MinGW to PATH.

Go to the Folder of the MinGW on your computer C:Program FilesCodeBlocksMinGwbin.
The following folder will open on your computer. Just copy the path on the address bar.

Setting up MinGW to PATH

Now refer to the steps mentioned in the Setting up PATH Variable in the previous section. After setting up the Environment path variable, proceed with the next steps.

Step 10: Compiler auto-detection.
As soon as you open up the Code::Blocks IDE, the Compilers auto-detection window will appear with the GNU GCC compiler status shown as Detected.

GNU GCC compiler Auto-Detection

Creating and Running a C Program in Code::Blocks.

Step 1: Open a New File in Code::Blocks.

Select File>>New>>Empty File and click on it to check whether the IDE is working properly.

New File in the Code Block

Step 2: Write a Hello World program in C.

Make a hello world program in C. Save it with the .c extension.

Write Hello World program in C

Step 3: Output of C Program.
Once you save, go to Build>>Run and the program will compile and run.
If the command prompt with hello world written on it appears on the screen below, then the code blocks have been successfully installed!

Output of Hello World Program in C

Conclusion

  • The source code is compiled using a C compiler for Windows to be understood by the machine (computer).
  • The C Compiler for Windows can be installed on a Windows system, first by only installing the compiler and second by installing a compiler with IDE as a plugin.
  • The C/GCC is the compiler used by the C language.
  • We have to set the path of the compiler in the Environment path variable so that it can be used in any directory.
  • To use C Compiler, the program must be saved with .C extension.

Leader badge

Code::Blocks is a free, open-source, cross-platform C, C++ and Fortran IDE built to meet the most demanding needs of its users. It is designed to be very extensible and fully configurable.

Finally, an IDE with all the features you need, having a consistent look, feel and operation across platforms.

Built around a plugin framework, Code::Blocks can be extended with plugins. Any kind of functionality can be added by installing/coding a plugin. For instance, compiling and debugging functionality is already provided by plugins!

We hope you enjoy using Code::Blocks!

The Code::Blocks Team

Features

  • Cross-platform
  • IDE
  • Compiler
  • Debugger
  • C,C++,Fortran

License

GNU Library or Lesser General Public License version 3.0 (LGPLv3)

Boost Your Marketing with Interactive Content Icon

Content Optimized For The Modern Marketer

User Ratings


4.7

out of 5 stars

★★★★★

★★★★

★★★

★★

ease
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5

4 / 5

features
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5

4 / 5

design
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5

4 / 5

support
1 of 5
2 of 5
3 of 5
4 of 5
5 of 5

4 / 5

User Reviews

  • All
  • ★★★★★
  • ★★★★
  • ★★★
  • ★★
  • Thanks for a great open source program

  • so goooooooooooooooooooooooood

  • I get the message: the application needs to be updated. contact the developer.
    I use MacBook Air m1

Read more reviews >

Additional Project Details

Languages

English

Intended Audience

Developers

User Interface

wxWidgets

Programming Language

C++, C

2004-12-20

If you are running Windows, it can be a bit confusing to get Code Blocks to run. Especially if you get mixed up in the GCC compiler installation stuff. Also, if you downloaded only the .exe of the IDE CodeBlock’s official site without the fancy extra files. A few years ago when I was trying to execute my first C program, I ran into a bunch of compiler errors and didn’t understand what was going wrong.

Mind you, this was the first time I was typing code on my computer. I just didn’t know that we were supposed to set up the GCC compiler separately. So I had to configure the compiler manually and it was a bit time-consuming.

In this post, I will try to present a solution to that problem. Just follow the steps below. This the most efficient and the easiest method to get Code Blocks up and running in a jiffy.

What’s the fastest and easiest way to install and set up Code Blocks with the GCC compiler?

Simple. Download this file and follow the steps below. It is preconfigured with the GCC compiler binary files so we will be up and running in a couple of minutes. We will explain the manual process of custom installing the IDE and the compiler later. Not for the sake of efficiency, of course. Just because knowing the intricacies involved in downloading the GCC compiler is a handy tool and will help you understand the basics of setting up IDEs. Select the full installation option from the second installation window.

Once that’s done, a window like the one above should pop-up on your screen. This is the auto-compiler detection window that will locate all the compilers in the installation folder and ask you to select the default one. Select GNU GCC and click Ok.

Technically, this should complete your installation process. However, if for some reason, you don’t see any automatic compiler detection window, here’s what you can do. 

Start code blocks normally. Head on to the Settings drop-down menu and select Compiler. Then inside the settings window, navigate to the tab titled ‘Toolchain executables’. Under the field ‘Compiler’s installation directory’, ensure that the last folder in the selected path is MinGW. Cross-reference with the image below and check if your program files are similarly labeled. That should fix most of the issues with the compiler installation.

The bin folder is where the compiler files are stored. So even if the problem persists even after you select the MinGW folder, it’s probably because the bin subfolder isn’t present. Try doing a fresh re-install on a different hard drive partition.

Step 1: Under the tab titles ‘Start here’, click on ‘Create a new project’. This will create a new project folder to store all the different code files.

Step 2: Select Empty project from the different categories displayed in the menu box. Don’t worry about the other options, we will get to know them later in this course.

Step 3: Enter the name of your project, this will be the folder where your individual files will be stored. Also, make a folder on your drive for the code you will write. In the long run, it pays off to organize your files neatly.

Step 4: Make sure that the selected compiler is the one we just installed. Check the boxes as shown in the screenshot to create the debug files.

Step 5: From the topmost toolbar, select the new file icon and create an empty file. This is where we’ll be writing the code. If you can’t see any toolbars, head on to the ‘View’ drop-down, select toolbars and select Main and Compiler, the toolbars should now appear on your screen. Similarly, if you can’t see the Manager window on the left and the Log window at the bottom, you can select to view them from the ‘View’ drop-down.

Step 6: Save the file with the extension ‘.c’ and your desired filename. Notice how the default folder is the project folder we created in step 2.

Step 7: Check the boxes shown below to include the files in the Debug folders.

Step 8: Write the code for Hello World and click the Build and Run icon located in the toolbar on the top. The icon has a yellow gear and a green play logo.

Step 9: You have successfully written your first C program. Join our free C programming course and get better at C!

Are you still having issues with the compiler?

Please comment below and I’ll be glad to help you out. And if you are not facing any problems and have successfully executed your HelloWorld code, don’t get too comfortable, the course is just beginning!

Can I just skip this software and have an online IDE, please?

Yep! You can compile all of your C code in your browser. There are many online IDEs on the web, but this one is my favorite. Using an online IDE just cuts through the hassle when you are not looking for any extra features except executing some code.

About the author

Umair has a Bachelor’s Degree in Electronics and Telecommunication Engineering. He also holds a Post-Graduate Diploma in Embedded System Design from the Centre of Development of Advanced Computing (Pune, India). Currently, Umair is pursuing his MS in Electronics Engineering from the University of Hertfordshire (Hatfield, UK).

Превью к статье об установке gcc на Windows

Для того, чтобы писать программы на C/C++ обычно достаточно установить какую-нибудь интерактивную среду разработки (IDE), например, Visual Studio или Eclipse, однако иногда (обычно в целях обучения студентов) требуется создавать программы в обыкновенном текстовом редакторе и компилировать приложение, используя консоль и компилятор gcc. В Unix системах он обычно установлен прямо «из коробки», а вот на Windows системах такой роскоши не наблюдается. Более того, у многих пользователей возникает множество проблем при установке компилятора. Поэтому нами было принято решение написать данную статью, чтобы помочь всем тем, кому пришлось или приходится мучаться с установкой этого компилятора на Windows.

Кстати, если вдруг на вашей Unix системе не установлен GCC, то поставить его можно командой sudo apt install gcc, введя свой пароль и согласившись на установку.

0. Прежде чем поставить компилятор GCC

Перед тем как приступить к установке этого компилятора на ваш компьютер, убедитесь в том, что GCC ещё не установлен на нём. Для этого откройте консоль (нажмите Win + R, введите в появившемся окне cmd и нажмите клавишу Enter) и введите следующую команду: gcc --version и нажмите Enter. Если компилятор уже установлен, то выполненная команда выдаст примерно следующую информацию:

gcc (GCC) 8.1.0
Copyright (C) 2018 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.

Если в окне консоли появилось сообщение с версией компилятора и другая информация о GCC (второй скриншот), значит компилятор уже установлен и больше дополнительно ничего делать не нужно. А вот если вывод командной строки такой:

"gcc" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом

— значит GCC ещё не установлен в системе, поэтому двигаемся дальше.

Появившееся окно консоли

Появившееся окно консоли

GCC уже установлен

GCC уже установлен

GCC не установлен

GCC не установлен

1. Скачиваем установщик компилятора

Чтобы поставить GCC на операционную систему Windows, необходимо скачать установочный файл для него. Сделать это можно здесь: equation.com/servlet/equation.cmd?fa=fortran. Найдите в таблице версию компилятора, которая вам больше нравится (мы рекомендуем скачивать самую последнюю, на текущий момент — это версия 8.2.0) и скачайте установщик для вашей системы (32 или 64 бит).

Выбор установочного файла

Выбор установочного файла

2. Установка GCC

После того, как файл был скачан, откройте в проводнике папку, в которую был скачан установщик и запустите его, кликнув по файлу дважды левой кнопкой мыши. Появится окно, требующее подтверждения действия. В нём нужно выбрать да (иначе ничего ставиться не будет).

Установщик начнёт работу и отобразит окно с консолью, а также окно с бежевым фоном, в котором попросит прочесть и принять (или отклонить) лицензионное соглашение. Нажимаем Accept.

Открывшееся окно с установщиком

Открывшееся окно с установщиком

Принимаем лицензионное соглашение

Принимаем лицензионное соглашение

После этого установщик попросит выбрать путь для установки, предложив по умолчанию путь C:mingw. Если вам категорически не нравится этот путь — измените его на более подходящий на ваш взгляд, в противном же случае просто нажмите Install.

Выбор папки для установки

Выбор папки для установки

Теперь остаётся только дождаться окончания распаковки архивов и установки их на компьютер. Как только все файлы будут установлены, инсталятор сообщит об этом, после чего нужно будет нажать на кнопку Finish.

Распаковка файлов и установка

Распаковка файлов и установка

Окончание установки

Окончание установки

3. Проверка установки

По завершении работы установщика перезагрузите компьютер и вновь откройте окно командной строки, введите команду gcc --version и нажмите Enter. На этот раз ответ от этой команды должен будет совпадать со вторым скриншотом из пункта 0. Если это не так, то скорее всего работа установщика была некорректно или преждевременно завершена, так что просто начните установку заново.

GCC установлен

GCC установлен

Поздравляем! Теперь на вашем компьютере установлен компилятор GCC и вы можете писать программы на языках C и C++, а компилировать их через командную строку!

4. Бонус. Компиляция программ с помощью GCC

Теперь, когда у вас установлен компилятор GCC, вы можете создавать программы на C/C++, используя только текстовый редактор и консоль. Для этого создайте новый файл и назовите его как угодно (например, hello_world). Задайте ему расширение .c вместо .txt. Напишите (или скопируйте) текст программы на С в этот файл. Откройте командную строку (Win + R, cmd) и введите следующую команду gcc hello_world.c и нажмите Enter. Если код не содержит ошибок, то результатом команды будет пустота. В противном же случае вы увидите все ошибки, который нашёл компилятор в программе с указанием места этой ошибки. При этом в проводнике появится файл a.out.exe, который будет являться исполняемым файлом для написанной программы. Чтобы запустить его введите в консоли a.out (для Unix-систем нужно писать ./a.out) и нажмите Enter.

Что ещё за a.out? Непонятно!

По умолчанию при компиляции программ GCC в качестве результата создаём исполняемый файл с именем a.out (если такой уже есть, то b.out и т.д.). Это может быть не очень удобно, если у вас в папке лежит сразу много программ, которые нужно скомпилировать и затем запустить. Неудобно хотя бы тем, что разобраться, что такое a.out, а что такое b.out и c.out может быть непросто. Именно поэтому мы рекомендуем компилировать программы с явным указанием имени выходного файла. делается это так: gcc имя_файла.c -o имя_программы.

В результате выполнения такой программы вместо a.out будет создаваться файл с именем, заданным в имя_программы. Например, если для файла hello_world.c мы хотим получить программу hello, то компилировать нужно такой командой: gcc hello_world.c -o hello.

Результат компиляции и запуска программы

Результат компиляции и запуска программы

Используя понятные имена выходных программ (исполняемых файлов), вы гарантируете себе простоту работы и сокращение времени на разбирательство спустя долгое время.

Возможно, также будет интересно: как установить Sublime Text для работы с C/C++.

Фото Перминова Андрея, автора этой статьи

Программист, сооснователь programforyou.ru, в постоянном поиске новых задач и алгоритмов

Языки программирования: Python, C, C++, Pascal, C#, Javascript

Выпускник МГУ им. М.В. Ломоносова

Понравилась статья? Поделить с друзьями:
  • Gns3 скачать windows 10 64 bit
  • Gnomoria не запускается на windows 10
  • Gnome skin pack для windows 7
  • Gnome disk utility скачать для windows
  • Gigabyte h510m h поддержка windows 7