2

I'm having some problems with Code::Blocks, and this is the output after / while compiling;

3|iostream: No such file or directory|
4|error: syntax error before "namespace"|
|In function `main':|
8|error: `cout' undeclared (first use in this function)|
8|error: (Each undeclared identifier is reported only once|
8|error: for each function it appears in.)|
||=== Build finished: 5 errors, 1 warnings ===|

My code is as follows;

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}
6
  • This won't fix it but you should say using namespace std;, although that's not recommended. Commented Feb 22, 2012 at 22:15
  • 2
    Are you sure that you have created C++ Console Project? Commented Feb 22, 2012 at 22:21
  • How do I do that? (I'm a complete newbie) I just did blank project? Commented Feb 22, 2012 at 22:22
  • File -> New Project -> Console Application -> C++ Commented Feb 22, 2012 at 22:23
  • Michal, post that as an answer, as it solved my problem! Commented Feb 22, 2012 at 22:24

2 Answers 2

4

You Have to Create Console C++ Project.

File -> New Project -> Console Application -> C++ .

It will set variables and linker options like basics libraries.

Sign up to request clarification or add additional context in comments.

Comments

1

The cout issue is because you should say

using namespace std;

The issue with iostreams is probably that you need to set the path to MINGW in your toolchain. You can access this from the Settings->Compiler and debugger settings->Global compiler setting->toolchain executables menus/tabs. Here select the part where MINGW is installed and that should take care of it.

1 Comment

My code does have using, but for some reason it got deleted when copying and pasting, I'll edit it. Thanks for the pointers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.