TheBeocro
TheBeocro

Reputation: 121

Code::Blocks Execution of 'mingw32-g++.exe Failed

yesterday I opened up Code::Blocks after a month or so of not using it, and I was messing around, writing some test code in C++. I compiled some programs correctly, then all of a sudden I got an error that I can't seem to solve:

-------------- Build: Debug in asdfsdfsdgf (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\aharman\Documents\CPP\asdfsdfsdgf\main.cpp -o obj\Debug\main.o Execution of 'mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\aharman\Documents\CPP\asdfsdfsdgf\main.cpp -o obj\Debug\main.o' in 'C:\Users\aharman\Documents\CPP\asdfsdfsdgf' failed.

Here is my code:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

I don't recall making any changes to anything related to Code::Blocks, so I don't know why it suddenly stopped working. I've been doing hours of research, and I just can't find the solution. Creating a thread is always a last resort for me, when I have given up trying to find an answer because it seems hopeless. Does anybody know what's going on here? Thanks in advance.

Upvotes: 3

Views: 23918

Answers (9)

alex
alex

Reputation: 1

I am writing for nowadays users who face this kind of problem and are just starting the journey of programming - are you sure you have downloaded the right file? "codeblocks-20.03mingw-setup.exe" not: "codeblocks-20.03-setup.exe" or other? Check twice, xx

Upvotes: 0

Vb Shankar
Vb Shankar

Reputation: 1

I had the same issue, with a little debugging I understood that "Linker for dynamic libs" has the wrong file name path.
Solution:- Go to Settings -> Compiler -> Toolchain executables -> in the Linker for dynamic libs: The default one is actually not at all present in the path. So select the one that is actually present.
So the new Linker for dynamic libs will have x86_64-w64-mingw32-g++.exe.

This should work.

Upvotes: 0

guestme
guestme

Reputation: 1

there is a problem with codeblocks 20.03 nosetup32bit version. g++.exe in bin folder is 64bit.

edit: yep if your version is win32 the most probably the problem with g++ executable which is x64 bit.

Upvotes: 0

Lacky YT
Lacky YT

Reputation: 13

So what solved the problem for me is this:

I went to Settings > Compiler and selected "toolchain executables" I went down to C compiler and clicked on the directory and re-selected "mingw32-g++.exe" and clicked "Open", it has give me an error "the file couldn't be find, because the names of the exe programs, that the codeblocks requires, and the names of files that is in the foulder "MinGW" can some different and the program can't find these exe files.

I believe the software experienced problems finding mingw32-g++.exe So all I had to do is to re-selected it.

Upvotes: 1

Susmit_sahu
Susmit_sahu

Reputation: 11

These solution above doesn't work for me so after couple of hours I figured what actually is going wrong.

There are two directories for mingw one located in c:\MinGW and other same in c:\programme files(×86)\codeblocks\ MinGW

So what's happening your live written script which you want to run is getting compiled in code blocks directory and the compiler plugin is somewhere else.

Change by going to Settings > Compiler and selected "toolchain executables and select bin directory present inside c:\programme files(×86)\codeblocks\ MinGW

And select appropriate extension gcc or mingw32-g++

Now it will compile default work file inside codeblock "Hello world"

Restart the software and open your project again to make it work.

Upvotes: 1

Amr Msiah
Amr Msiah

Reputation: 1

So what solved the problem for me is this:

I went to Settings > Compiler and selected "toolchain executables" I went down to C compiler and clicked on the directory and re-selected "mingw32-g++.exe" and clicked "Open" and I Run the project again and it worked just fine.

I believe the software experienced problems finding mingw32-g++.exe So all I had to do is to re-selected it.

Upvotes: 0

AJcleverprogrammer
AJcleverprogrammer

Reputation: 61

You just need to rename the file to mingw32-g++ : C:\mingw64\bin => find a file with -g++ in the end, make sure to save a current name, then rename it to mingw32-g++, it works for me.

Upvotes: 1

SuperGoA
SuperGoA

Reputation: 245

Try right clicking on your project > properties > build targets. Look in the box labeled "Build Target Files" and ensure that the correct source files are selected.

Upvotes: 0

Aero&#39;s Assist
Aero&#39;s Assist

Reputation: 33

It may be possible that Code::Blocks is not looking in the correct location. First i recommend going to setting - compiler and debugger - toolchain executables. Then within Compiler's installation directory click Auto detect. Press OK and then try again. I hope this helped. Goobyebye.

Upvotes: 1

Related Questions