help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hello World!


From: Bjørnar Libæk
Subject: Hello World!
Date: Thu, 13 Jan 2005 20:19:39 +0100
User-agent: Opera M2/7.54 (Linux, build 751)

Trying to build the helloworld program (below).
When building, I get this:

g++ -c -o main.o -MD -I/usr/include -I/usr/include/g++-3 main.cpp
HelloWorld/main.cpp: In function `int main(int, char**)':
"main.cpp": HelloWorld/main.cpp error: `cout' undeclared in namespace `std' at line 6 "main.cpp": HelloWorld/main.cpp error: `endl' undeclared in namespace `std' at line 6 "main.cpp": HelloWorld/main.cpp error: `cout' undeclared in namespace `std' at line 7 "main.cpp": HelloWorld/main.cpp error: `cin' undeclared in namespace `std' at line 9 "main.cpp": HelloWorld/main.cpp error: `cout' undeclared in namespace `std' at line 11 "main.cpp": HelloWorld/main.cpp error: `endl' undeclared in namespace `std' at line 11
 GNU C++ Compiler exited with error code: 1
Build cancelled due to errors


However, if I remove the "-I/usr/include/g++-3" option, it builds and runs ok. The g++-3 directory is present, and readable.

sh#> locate iostream.h
/usr/include/c++/3.3/backward/iostream.h
/usr/include/c++/3.4/backward/iostream.h
/usr/include/g++-3/iostream.h
sh#>

Why the errors?


[main.c]
#include <iostream>

int main(int /*argc*/, char* /*argv*/[])
{
  std::cout << "Hello world!" << std::endl;
  std::cout << "Please enter a character and press return:";

  std::cin.get();

  std::cout << "Goodbye world!" << std::endl;
  return 0;
}
[/main.c]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]