LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-10-2008, 04:30 PM   #1
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Rep: Reputation: 15
gcc error - "iostream: No such file or directory"


Trying to compile the following code 'test.c':
Code:
#include <iostream.h>
#include <stdio.h>

int main(void) {
  printf("Hello World!\n");
}
With 'gcc -o test test.c', I get the error:
Code:
test.c:1:22: iostream.h: No such file or directory
Changing to without the .h extension, '#include <iostream>', the error remains:
Code:
test.c:1:20: iostream: No such file or directory
I tried this on two different servers, one with Linux 2.4.21-47.0.1.ELsmp and gcc 3.2.3 (Red Hat Linux 3.2.3-59), the other with Linux 2.6.9-55.ELsmp and gcc 3.4.6 (Red Hat 3.4.6-9). Both gave the same error.

The only thing I could think of is that this has something to do with the gcc path. On the first server, gcc is located at '/usr/lib/gcc-lib/i386-redhat-linux/3.2.3', and 'locate /iostream.h' found two instances:
Code:
/usr/include/c++/3.2.3/backward/iostream.h
/lib/ssa/gcc-lib/i386-redhat-linux-gnu/3.5-tree-ssa/include/c++/backward/iostream.h
I assume the first one is the one I want to include, though I'm not sure. On the second server, gcc was at '/usr/lib/gcc/i386-redhat-linux/3.4.3', and one instance of iostream.h was found:
Code:
/usr/include/c++/3.4.3/backward/iostream.h
On both servers, stdio.h was located at
Code:
/usr/include/stdio.h
(on the first server it was also in a few other places)

Are the /backward/iostream.h the files I want to include in the gcc path?

And if so, just how do I modify the gcc path? I did not see a configure, .conf etc. file in either gcc's directory. I did see a 'specs' file which seems to be some sort of configuration file, but I couldn't find a 'path' or 'include' value in it.
 
Old 05-10-2008, 06:37 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2015, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 15,302

Rep: Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935
I am no coder, but I see some c++-headers, so
'g++ -o object.o hello.cpp' works fine. The object prints: "Hello World !" when executed.
 
Old 05-10-2008, 06:45 PM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656
iostream is a C++ header, so you need to use g++ to compile it. Using <iosteam.h> is depreciated. Use <iostream> instead and
either explicitly precede the commands with the namespace or use the line "using namespace std;".

Another option is to not include iostream.h. The stdio.h header includes the printf function.

Just an FYI: The standard C functions have there own manpages (may need to install a document package) so you can enter "man 3 printf" or example. The function definition will include which header needs to be included.

Last edited by jschiwal; 05-10-2008 at 06:49 PM.
 
Old 05-10-2008, 08:21 PM   #4
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by knudfl View Post
I am no coder, but I see some c++-headers, so
'g++ -o object.o hello.cpp' works fine. The object prints: "Hello World !" when executed.
Ah, so it was a simple mistake - I was using 'gcc' instead of 'g++' Thanks guys. Using g++ works.
 
Old 06-03-2012, 08:59 PM   #5
The_sunqi
LQ Newbie
 
Registered: Jun 2012
Posts: 1

Rep: Reputation: Disabled
test

Last edited by The_sunqi; 06-03-2012 at 09:01 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"mount: not a directory" pmount error when file system is out kaz2100 Linux - General 0 12-18-2007 02:10 PM
C++ iostream - getting "deprecated header" error jdruin Programming 3 09-28-2004 07:31 AM
Error in man command "sh: line 1: /usr/bin/gtbl: No such file or directory" MinA Slackware 1 09-06-2004 06:36 PM
error while trying to install program: "X11/Xlib.h: No such file or directory" nate1 Linux - Newbie 3 05-21-2004 08:08 AM
Error message "no such file or directory" Luisa Linux - General 0 02-13-2004 11:19 AM


All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration