1

So I just recently downloaded a C++ IDE called Code::Blocks and made a new project. But when I tried to Build and Run it, the code gave some errors. I know that it isn't a problem with syntax or anything like that because I ran the default code that Code::Blocks provided. The error is the following:

Project/Target: "firstcpp - Debug":
  The compiler's setup (GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
  Probably the toolchain path within the compiler options is not setup correctly?!
  Do you have a compiler installed?
Goto "Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables" and fix the compiler's setup.

Tried to run compiler executable 'C:\MinGW/bin/gcc.exe', but failed!

Skipping...
Nothing to be done (all items are up-to-date).


It seems to me like there is some kind of issue with the C++ compiler, but I thought Code::Blocks already came with a C++ compiler, so I'm not too sure what the issue here. I also followed their instructions to go to Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables, but I'm not too sure what they mean by fix the compiler. Here is a screenshot of what I'm seeing:

Also here's info on my PC if you need it:

At this point I'm not too sure what to do to fix this problem. I have asked my friends about this problem(they have already successfully downloaded and used Code::Blocks), and they said that they never encountered this problem while they were installing it.

Aiden Chow
  • 391
  • 6
  • 17
  • Its a really interesting question I might say. It seems that your compiler is missing – John Henry 5 Nov 13 '20 at 01:14
  • Well does `C:\MinGW/bin/gcc.exe` exist? And how did you install mingw? – drescherjm Nov 13 '20 at 01:14
  • 1
    @drescherjm No. Do I have to download anything to get it? – Aiden Chow Nov 13 '20 at 01:19
  • I believe Some Code::Blocks downloads include a version of mingw some don't – drescherjm Nov 13 '20 at 01:20
  • hmm thats interesting – John Henry 5 Nov 13 '20 at 01:20
  • Here is some info on installing mingw: [https://stackoverflow.com/questions/61497394/installing-the-latest-version-of-mingw-w64-on-windows](https://stackoverflow.com/questions/61497394/installing-the-latest-version-of-mingw-w64-on-windows) This has the added benefit of installing a more recent version. I have the msys2 version. – drescherjm Nov 13 '20 at 01:21
  • 1
    @drescherjm Oh I thought Code::Blocks came with the compiler. I asked my friends and they said they didn't have to install an extra compiler and it worked for them. – Aiden Chow Nov 13 '20 at 01:24
  • It depends on the download. Get one of the .exe downloads here: [http://www.codeblocks.org/downloads/26](http://www.codeblocks.org/downloads/26) with mingw in the filename probably: `codeblocks-20.03mingw-setup.exe` – drescherjm Nov 13 '20 at 01:25
  • 1
    [Good instructions for installing an up-to-date mingw](https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2). This distribution comes with an impressive ecosystem of pre-built add-on libraries you can install and use. Save you a lot of time when you want the likes of boost or SSL support in your program. – user4581301 Nov 13 '20 at 01:51
  • What an interesting solution you have there! Well done. I am interested in whatever new things you might come up with in your futures! – John Henry 5 Nov 13 '20 at 02:00
  • 1
    There are serveral download files: codeblocks-20.03-setup.exe (IDE without compiler ~ 30 MB); codeblocks-20.03mingw-setup.exe (IDE + MinGW ~ 90 MB); codeblocks-20.03mingw-32bit-setup.exe (IDE + MinGW + compile to 32 bits app). Make sure to get the right one. If there are something wrong, remove the installed version, and install a new one. This is the easiest practice. – ytlu Nov 13 '20 at 07:28

2 Answers2

1

You need to ensure that you have a working installation of the GNU Compiler Collection, and that the paths you select for your toolchain exist.

If you don't already have GCC Installed, the easiest way would be to download a Code::Blocks distribution that comes pre-bundled with MinGW from the download site. However, it's also possible for you to install GCC through other means, such as:

In either case, you need to select the installation path that contains the bin directory when setting up the toolchain in Code::Blocks.

Human-Compiler
  • 11,022
  • 1
  • 32
  • 59
0

In case you didn't notice, C::B formed the path to compiler with both "\" back slashes and "/" slashes, which simply isn't a valid Windows path !! Slashes are used in Linux not Windows! But for some reason C::B is not getting this. And probably your Mingw is well set !! C:\MinGW/bin/gcc.exe should be C:\MinGW\bin\gcc.exe

I had pretty hard time trying to fix this in win 7 32 bit/C::B version 20.03 but with no success, i checked all available options and settings, and actually i started to think that it's a bug.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 15 '21 at 01:14