Author Topic: cannot compile  (Read 1285 times)

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
cannot compile
« on: September 10, 2018, 11:23:00 pm »
I just installed Code::Blocks and Mingw32 gcc on my new computer after my old computer crached.
I started working on a new project, did some coding and tried to compile. I got error messages, so several times I made corrections and tried again.
At a certain moment I got no more error messages but  the message "Execution of 'mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users...\priemzeef' failed"
From that moment I get only that message, also when I try to recompile older projects that used to compile fine on my old computer.

This is the build log:

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

mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef\main.cpp -o obj\Debug\main.o
Execution of 'mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef\main.cpp -o obj\Debug\main.o' in 'C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef' failed.

Another problem: when I click "save everything" I get an error message (see attachment), and when I open Code::Blocks I have to reload the project I was working on.

Wobien

Online Commaster

  • Multiple posting newcomer
  • *
  • Posts: 85
Re: cannot compile
« Reply #1 on: September 11, 2018, 03:04:17 am »
Try installing Code::Blocks NOT in "Program Files" or other system-crucial folders, windows is really paranoid when it comes to write permissions in those folders.

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #2 on: September 11, 2018, 12:14:32 pm »
Thank you Commaster, that solved the "save everything" problem.

But I still have the compiling problem. My project is a console application, and when I started it (that was on my new computer) I could compile the "hello World" program you get when you start a console application. This morning I tried to repeat that: I started a new console application and tried to compile the code I recieved:


#include <iostream>

using namespace std;

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


The build log is:


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

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

That means that something has changed since I started my project, 2 days ago. What could that be?? As far as I know I didn't change anything.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2060
Re: cannot compile
« Reply #3 on: September 11, 2018, 07:15:23 pm »
Anti Virus? Modern Anti virus think that compiler are viruses and block them from creating executables
Did you restarted the PC?
Did it worked with the current setup sometime?

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #4 on: September 11, 2018, 08:51:03 pm »
Thank you for your remarks BlueHazzard,

I swiched off my antivirus and tried to compile, but that didn't help.
I restarted the PC several times, but no compiling.
I don't understand your last remark.


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2060
Re: cannot compile
« Reply #5 on: September 12, 2018, 01:14:27 am »
Quote
I don't understand your last remark.
Have you changed something since the last time it worked? Did it never worked, or did it worked one time and then never again?

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #6 on: September 12, 2018, 09:14:18 am »
Hi BlueHazzard,
Working on my new project, I compiled succesfully several times. When I recieved the message:

Execution of 'mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef\main.cpp -o obj\Debug\main.o' in 'C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef' failed.
for the first time I had not changed anything.
After  Commaster 's mail I deinstalled  Code::Blocks and reinstalled it in C::\.


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2060
Re: cannot compile
« Reply #7 on: September 12, 2018, 10:37:56 am »
Go into Settings->Compiler->Tool chain executables->Auto-detedt

If this throws an error, press the "..." and brows to your compiler installation...

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #8 on: September 12, 2018, 10:58:55 am »
Hi BlueHazzard
I attached the message I get when I do that.

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #9 on: September 12, 2018, 11:09:20 am »
Now I opened the Toolchain executables I see something else: underneath the compiler directory I see:
NOTE: All programs must exist either in the "bin" sub-directory of this path, or in any of the "Additional paths".

I clicked Additional paths and found an empty window. Is that OK?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2060
Re: cannot compile
« Reply #10 on: September 12, 2018, 02:04:34 pm »
Quote
I attached the message I get when I do that.
This seems to be OK... And it still does not work?
Try Build->Rebuild and post again the Log from the "Build Log" tab


@devs: We need more output for this kind of error... For example the full path to the compiler executable, probably an output of "gcc" -v and probably some more resolving why the execution failed.

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #11 on: September 12, 2018, 02:34:49 pm »
Quote
@devs: We need more output for this kind of error... For example the full path to the compiler executable, probably an output of "gcc" -v and probably some more resolving why the execution failed.

And some info about the OS and CB version

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #12 on: September 12, 2018, 03:45:56 pm »
This is the Build Log after Rebuild:

-------------- Clean: Debug in priemzeef (compiler: GNU GCC Compiler)---------------

Cleaned "priemzeef - Debug"

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

mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef\main.cpp -o obj\Debug\main.o
Execution of 'mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef\main.cpp -o obj\Debug\main.o' in 'C:\Users\wobie\Documents\Codeblocks\recreatie\priemzeef' failed.

The path to mingw is C:\MinGW
I attached the About window from CB
My OS is Windows 10


Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #13 on: September 12, 2018, 04:24:32 pm »
The last Windows 10 update adds optional protection to folders under Documents, so untrusted programs can't modify files inside those folders; Did you activate this option in Windows Defender?.

Copy the project folder outside of Documents (p.e. C:\CBProjects) and try to compile the copy.
If this does not work try opening a cmd console where main.cpp resides and execute

Code: [Select]
mingw32-g++.exe -Wall -fexceptions -g  -c main.cpp -o main.o
Post the output of the command here.
« Last Edit: September 12, 2018, 04:26:10 pm by Miguel Gimenez »

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #14 on: September 12, 2018, 06:17:49 pm »
I copied the project folder outside of documents and tried to compile. No succes.

I attached the output of the cmd console.

I also attached the mingw/bin directory: there is no file mingw32-g++.exe, but a file mingw32-gcc.exe

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2060
Re: cannot compile
« Reply #15 on: September 12, 2018, 07:03:29 pm »
OK, in the CMD type this in this order:
Code: [Select]
set PATH=%PATH%;c:\MinGW\binand then
Code: [Select]
mingw32-g++.exe -Wall -fexceptions -g  -c main.cpp -o main.o
The first command will add the MinGW compiler directory to your path so cmd can find the compiler command. The second command will try to build your source without codeblocks, so we can see if something is blocking the compiler.

[Edit:] as soon as you close the cmd you will have to retype the first command.

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #16 on: September 12, 2018, 07:17:04 pm »
Still no succes... (see attachment)

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #17 on: September 12, 2018, 07:27:06 pm »
There is no file mingw32-g++.exe in the directory c:\MinGW\bin. See my second attachement in my post at 07:17:49 pm

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #18 on: September 12, 2018, 07:31:22 pm »
Try

Code: [Select]
mingw32-gcc.exe -Wall -fexceptions -g  -c main.cpp -o main.o

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #19 on: September 12, 2018, 07:56:14 pm »
Now Mingw reacts, but still no succes...

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #20 on: September 12, 2018, 08:01:41 pm »
It seems G++ is not installed (is an option). Try

Code: [Select]
mingw-get update
and then

Code: [Select]
mingw-get install g++
After this the original command (with mingw32-g++.exe) should work. Probably the compiler executables must be configured again in CB.


Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #21 on: September 12, 2018, 08:22:39 pm »
Yes, it compiles!

Miguel Gimenez and BlueHazzard, many thanks!

The only thing I don't understand is how it is possible that it compiled when I started the project???

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #22 on: September 12, 2018, 08:34:07 pm »
Do you have two MinGW installations?. Probably there was one prior installation of MinGW bundled with Code::Blocks (under Program Files) that was working, and later the automatic detection found the c:\mingw one (as it is the expected path for MinGW).

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #23 on: September 12, 2018, 11:16:12 pm »
Where would that Mingw installation bundled with Code::Blocks be? In a subdirectory of the Code::Blocks directory in Program Files?

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 130
Re: cannot compile
« Reply #24 on: September 13, 2018, 12:38:04 pm »
IIRC it was installed under Program Files\Codeblocks, but I have not installed the bundled version in years.

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
Re: cannot compile
« Reply #25 on: September 14, 2018, 07:40:27 pm »
I don't think I have two MinGW installations. In the Directory where Code::Blocks is installed I can't find anything that looks like MinGW.