0

I'm currently trying codeblocks for my c++ programming but i'm having trouble getting it to compile, i have not had this problem in the past and i've only developed it recently, i have searched google in vain for a solution and the closest i came was Code::Blocks Compilation Errors which did not fix my problem i have tried numerous times to uninstall and install both codeblocks and mingw. the error is:

1|fatal error: iostream: No such file or directory|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|

it's just a basic hello world program in my settings i have the c++ compiler listed as mingw32-g++.exe. i have been trying for days to get this to work, please help.

#include <iostream> 
using namespace std; 
int main()
{
    cout << "hello world\n"; 
    return 0;
}
Community
  • 1
  • 1
elder south
  • 463
  • 2
  • 4
  • 14
  • What are you using iostream and iostream.h? – Castiblanco Mar 29 '13 at 20:35
  • yes, it's just a straightforward #include using namespace std; int main(){cout << "hello world\n"; return 0;} – elder south Mar 29 '13 at 20:37
  • 1
    Have you seen this FAQ? http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_My_simple_C.2B.2B_program_throws_up_lots_of_errors_-_what_is_going_on.3F – john Mar 29 '13 at 21:10
  • thank for the reference john, i fixed the .c's on my files but now i'm coming up with ||=== helloworld.cpp, Debug ===| obj\Debug\main.o||In function `main':| c:\Users\jnsouth\cpp\helloworld.cpp\main.cpp|6|multiple definition of `main'| obj\Debug\euler35.o:c:\Users\jnsouth\cpp\helloworld.cpp\hello.cpp|5|first defined here| ||=== Build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===| – elder south Mar 29 '13 at 21:31
  • Well I'm not experienced with code blocks but it seems you have combined more than one program in your compilation. You have a helloworld.cpp and a euler35.cpp? Must admit I'm not really understanding those error messages in detail but it is telling you that somehow you've managed to include more than one main function. – john Mar 29 '13 at 21:35

5 Answers5

3

I had the same problem, and it was that I was saving the file as a c file (ex. HelloWorld.c). When I changed the file to HelloWorld.cpp started to works. So, change the file name to .cpp

Luis E. Vega
  • 399
  • 2
  • 14
0

Did you misplace your iostream file?

Perhaps you could confirm this issue with another compiler.

simpleb
  • 53
  • 5
0
/* Using standard C++ calling (note that you should use namespace std for cout or add using namespace std;) */ 

#include <iostream>

int main()
{
    std::cout<<"Hello World!\n";
    return 0;
}
Hassan Maher
  • 73
  • 1
  • 3
0

yeah i solve this just use a c++ compiler like g++ g++ your project -o test and then./test your project = the name of your text codes and 1 more note if u use g++ and your file is in desktop go to file manager and go to desktop and click right on the desktop (file manager) and click on open terminal and then boom finish it

0

I too had the same "#include< iostream > " No such file or directory ERROR!! But probably in my case that was the extension problem. Codeblocks saves it in .c (extension by default.) Just Save the program by its name followed by cpp. Like "Myprogram.cpp". Hope this helps.....