Eclipse c++ build error: no such file or directory - c++

I installed MinGW and CDT following some tutorials. I'm trying to compile and run "hello world" code. There are no errors in eclipse but when I compile the code I get this error:
22:48:32 **** Incremental Build of configuration Debug for project test3 ****
Info: Internal Builder is used for build
g++ "-IC:\\MinGW\\lib\\gcc\\mingw32\\4.8.1\\include\\c++" "-IC:\\MinGW\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\mingw32" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\test3.o" "..\\src\\test3.cpp"
g++: error: CreateProcess: No such file or directory
22:48:32 Build Finished (took 135ms)
The code:
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}

Might be a silly question to ask, but did you save the file somewhere before building it? I've had an error like this that was solved by saving it on my Desktop or wherever.
Edit: There seems to be several people with problems using MinGW. You mentioned you looked at previous stackoverflow questions, do they include these:
Eclipse CDT error: Unable to compile
MinGW error: No such file or directory exists
Other solutions suggest you should try compiling the program via command line, which...shouldn't be a problem since it's just "Hello, World".

Related

VS code c++ debugger setup using GDB does not work

So here's my problem. I have downloaded mingw g++ by using msys according to the official vs code website
Here are my files:
Now, when I try to build I get this error:
> Executing task: g++ -std=c++14 -g -o myfile.exe myfile.cpp <
cc1plus.exe: fatal error: myfile.cpp: No such file or directory
compilation terminated.
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command g++ -std=c++14 -g -o myfile.exe myfile.cpp" terminated with exit code: 1.
And if I do have a .exe file:
edit: I also started getting errors with
#include <iostream>
I would make this a comment if I could. What is the name of the file where you have written #include <iostream>?* I think if you change the name of that file to "myfile.cpp", you might stop getting that error. You will probably get a different error saying that "main() cannot be found" or something like that, but that's an improvement from your current spot.
*I see it's O3.cpp. Try changing that to myfile.cpp.

a fatal error in compiling a c++ program

I am using eclipse kepler for C++, in compiling a simple hello world program I saw this error.
c:\mingw\include\_mingw.h:73:20: fatal error: w32api.h: No such file or directory
while the whole windows is as bellow.
09:15:59 **** Incremental Build of configuration Debug for project project1 ****
Info: Internal Builder is used for build
g++ "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\backward" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include-fixed" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\mingw32" "-IC:\\MinGW\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\project1.o" "..\\src\\project1.cpp"
In file included from c:\mingw\include\wchar.h:53:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\src\project1.cpp:2:
c:\mingw\include\_mingw.h:73:20: fatal error: w32api.h: No such file or directory
compilation terminated.
09:16:01 Build Finished (took 2s.535ms)
what can I do?
my code is this
#include <iostream>
using namespace std;
int main()
{
cout<<"hello world";
}
In my case i've solved like this:
Go to MinGW Installation Manager.
Select "Basic Setup" from installation list and tick the package "mingw32-base-bin".
From the installation tab select "Apply Changes".
the problem is related to the MinGW installer. there is a package that must be installed, but it didn't install it. go to the MinGW installer and add the ming-w32-w32.api and then apply changes from installation menu.

code::blocks createprocess "No such file or directory" no idea how to fix

I am VERY new to using the code::blocks compiler and It doesn't seem to be working.
I downloaded the code::blocks and mingw package of of there website and I ran a very simple program that would say "hello world" and every way I try it I keep getting this error:
mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\Owner\Desktop\console_test\main.cpp -o obj\Debug\main.o.
I have looked at all the other articles in stack overflow and I keep seeing people saying to set the enviroment variables or run mingw in a different directory but I have no idea how to do that.
The program:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}

Exec Format Error Eclipse CDT

I have a basic C++ program in Eclipse CDT:
#include <iostream>
using namespace std;
int main()
{
std::cout << "Hello World!";
}
However, when I try to build it, I get an Exec Format Error. Here is the output produced by the compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o hey.o "..\\hey.cpp"
g++: error: spawn: Exec format error
I am using MinGW Toolchain. I am on 64-bit Windows, and I think that may have something to do with it. Would anyone know how to get this program running?
Edit
Running the exact command in command prompt in the directory where my source file is works just fine, without throwing errors, but it still doesn't work in Eclipse
So, I have fixed this myself by installing the 64-bit version of MinGW (http://sourceforge.net/projects/mingw-w64/). It now compiles and builds noramlly

Compilation error on Eclipse CDT

I have MinGW installed on my computer (I just use the one shipped with Strawberry perl). I can compile things just fine from the command line. Using Eclipse CDT, however, results in weird errors. Using the c++ hello world default project which comes with Eclipse, compilation in CDT fails with these errors:
\**** Internal Builder is used for build \****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp
..\src\hw.cpp:9:20: error: iostream: No such file or directory
..\src\hw.cpp: In function 'int main()':
..\src\hw.cpp:13: error: 'cout' was not declared in this scope
..\src\hw.cpp:13: error: 'endl' was not declared in this scope
Build error occurred, build is stopped
Time consumed: 263 ms.
But when I run g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp on my command line compilation goes just fine. All of the proper header files (like iostream) are in my path variable. What eclipse settings do I need to change to make this work?
Here's the file I'm trying to compile:
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
I experienced this only a few days ago, the problem turned out to be that I had both g++4.3 and g++4.4 installed and Eclipse was getting confused. I uninstalled 4.3 and the problem went away.