Tomasz Iwaszko
Tomasz Iwaszko

Reputation: 187

gcc don't see standard header files

I've got simple program in c++ which include two standard headers

stdio.h and iostream. When I type

gcc main.c

I got error: fatal error: iostream: There is no file or directory even if I rewrite iostream to iostream.h But when I type:

g++ main.c

everything works fine. I have to fix this problem cause my IDE(CodeLite) probably use gcc command

Upvotes: 0

Views: 585

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254501

That's how you'd compile a C source file. If you're compiling C++ rather than C, then

  • rename the file extension to something GCC recognises as C++, such as .cpp, .cxx or .cc
  • invoke the compiler as g++ rather than gcc

Upvotes: 2

Related Questions