Code::Blocks Forums

User forums => Help => Topic started by: zhousama on February 21, 2014, 09:26:00 pm

Title: Hello World Fail
Post by: zhousama on February 21, 2014, 09:26:00 pm
Hello,

I'm just starting to learn C++ and installed Codeblocks. I copied the HelloWorld program but immediately get an error:
C:\Users\...\New folder\Untitled5.c|2|fatal error: iostream: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is the program:
// my first program in C++
#include <iostream>

int main()
{
  std::cout << "Hello World!";
}

I'm think the error lies in the standard libraries not being included in the build path, but I'm not sure which directories to include. Any ideas?

Thanks in advance!
Title: Re: Hello World Fail
Post by: BlueHazzard on February 21, 2014, 09:48:42 pm
you are trying to compile a c++ program with a c compiler. C::B looks at the file ending to get the right compiler. So if you want to compile a c++ program  (iostream) your file needs the cpp or cxx ending and not c.

greetings

PS. please use code tags for log and code in this forum
Title: Re: Hello World Fail
Post by: quneur on May 09, 2014, 04:53:24 pm
int main requires a return type.
Title: Re: Hello World Fail
Post by: stahta01 on May 09, 2014, 05:27:58 pm
BlueHazzard is correct in the cause.

FAQ related to this issue is http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

Tim S.