问题
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;
}
回答1:
You Have to Create Console C++ Project.
File -> New Project -> Console Application -> C++ .
It will set variables and linker options like basics libraries.
回答2:
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.
来源:https://stackoverflow.com/questions/9403907/codeblocks-compilation-errors