I am using the CodeLite IDE. I compiled the following program using CodeLite (It is a C++ program):

#include <iostream.h>
int main()
{
cout << "Hello World\n";
return (0);
}

It returns this message:

g++ -c "/home/keagan/.coding-work/Hello/" -g -o ./Debug/printamessage.o "-I." "-I."
/home/keagan/.coding-work/Hello/printamessage.cc:1:23: error: iostream.h: No such file or directory
/home/keagan/.coding-work/Hello/printamessage.cc: In function ‘int main()’:
/home/keagan/.coding-work/Hello/printamessage.cc:4: error: ‘cout’ was not declared in this scope
make[1]: *** [Debug/printamessage.o] Error 1
make: *** [All] Error 2

Anybody have any idea how to fix this? It seems to be a library issue...

--thanks, techningeer

Dani AI

Generated

Good catch by — the failure was caused by using the old, non‑standard header name that modern C++ libraries no longer provide. Modern implementations follow the ISO standard and place the iostream facilities in the std namespace, so the compiler could not find the legacy header and then flagged that the stream object wasn’t declared.

Practical checklist to avoid the same error:

  • Make sure the project is being built as C++ (the .cc extension is fine) and the compiler invoked is a C++ compiler.
  • Update legacy includes to the standard library header names (the ones without the old “.h” suffix) and either qualify stream names with the std:: namespace or bring just the needed names into scope with a using declaration.
  • If the standard headers are actually missing on the system (rare), install the C++ compiler and standard-library development packages for the platform (for example, g++ or build‑essential on Debian/Ubuntu, or the equivalent dev package for other distributions).

Style and portability notes: prefer limiting scope of using declarations (or fully qualifying std:: names) rather than putting a broad using namespace std; directive into headers. That keeps larger projects safer from name collisions. When porting old code, change the headers and then fix any unqualified identifiers — most problems will be naming/namespace related rather than linker or library issues.

As confirmed, the change recommended by fixes the build. If further errors appear after updating the includes and namespaces, the new compiler error lines will point to what still needs adjustment.

Recommended Answers

All 2 Replies

#include <iostream> Drop the .h
Oh, and use either

using std::cout;

or

std::cout << "...";

or you will get more errors related to sytax.

Thanks! Your solution worked!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.