Problem with broken complier in Linux Fedora Core 1

  • Supasiri
  • Born
  • Born
  • No Avatar
  • Joined: May 25, 2004
  • Posts: 4
  • Loc: US
  • Status: Offline

Post May 25th, 2004, 9:11 am


Hi,
I'm a newer with linux. I tried to run this code to check the gcc complier:

#include <iostream.h>
int main (int argc, char **argv)
{
cout << " Hello world";
}

I always got this result:

test.c:1:22: iostream.h: No such file or directory
test.c: In function `main':
test.c:4: error: `cout' undeclared (first use in this function)
test.c:4: error: (Each undeclared identifier is reported only once
test.c:4: error:s for each function it appears in.)

I checked in /usr/include/c++/3.3.2/backward/, I found ' iostream.h ' there.
I set PATH to this directory. I still got the same result.

I have no idea what to do next. Does anyone know how to fix it please let me know.

kind regards,
:lol:
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 25th, 2004, 9:11 am

  • pifua
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 24, 2004
  • Posts: 10
  • Status: Offline

Post May 25th, 2004, 11:14 am

you have to specify a -I<path to folder with iostream.h> key in your compiler directive.
  • andrushok
  • Novice
  • Novice
  • User avatar
  • Joined: May 21, 2004
  • Posts: 24
  • Status: Offline

Post May 25th, 2004, 1:25 pm

Quote:
you have to specify a -I<path to folder with iostream.h> key in your compiler directive.


I think it is not nessesary. The real reason is different, however I do not know. Usually

Code: [ Select ]
gcc -c test.c
gcc -g test.o -o test
  1. gcc -c test.c
  2. gcc -g test.o -o test

is enough to create "Hello, World" application.
Could you check the gcc packages using:
Code: [ Select ]
rpm -qa|grep gcc
rpm -qa|grep glibc
  1. rpm -qa|grep gcc
  2. rpm -qa|grep glibc

You also can try to reinstall gcc/glibc packages and try again. This code should be compiled/linked without any -I flags.

P.S. I do not have experience with Fedora, but I have some practice with RedHat. I think there is no significant difference.
  • Supasiri
  • Born
  • Born
  • No Avatar
  • Joined: May 25, 2004
  • Posts: 4
  • Loc: US
  • Status: Offline

Post May 25th, 2004, 4:59 pm

Thanks for your tips. I have tried the first tip

" to specify a -I<path to folder with iostream.h> key in compiler"

but it still doesn't work.

About rpm, I don't know how to recomplie this packages. When I tried to uninstall gcc/glibc packages, I always got the error about the dependencies. What command should I use in order to do so?

Thank you,
Regards.
  • andrushok
  • Novice
  • Novice
  • User avatar
  • Joined: May 21, 2004
  • Posts: 24
  • Status: Offline

Post May 26th, 2004, 6:53 am

It is not nessesary to recompile gcc/glibc. Of course, if gcc broken it is not possible to recompile itself :shock: . At first you should remove gcc/glibs and all dependences step by step (use "man rpm" for details, as I remember "rpm -e pkg_name" allows you delete the package). Remember these dependences. You have to restore them, of course. After that download gcc and glibc RMPs (not sources) and their dependences. It will be better to find these RPMs for Fedora. Unfortunately I do not know where you can find them, maybe on ftp.redhat.com. And install it again. Maybe it helps you. I do not have any idea, why gcc cannot find/accept standard include file. It looks like it has something wrong inside :( .
  • tdopsdarock
  • Born
  • Born
  • No Avatar
  • Joined: Jun 08, 2005
  • Posts: 1
  • Status: Offline

Post June 8th, 2005, 8:30 am

Hey, I had the same problem i think you should use the namespace command like this

#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
return 0;
}

cheers
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post June 8th, 2005, 8:25 pm

thats a C++ program.
gcc compiles a C program.
g++ compiles a C++ program.

therefore, you would not use gcc at all, but
Code: [ Select ]
g++ -c test.cpp
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • shut up
  • Born
  • Born
  • User avatar
  • Joined: Jun 11, 2005
  • Posts: 2
  • Loc: china
  • Status: Offline

Post June 13th, 2005, 12:10 am

I uesd to write :
gcc -ggdb3 -o xxx /path/xxx.c
./xxx.c
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post June 13th, 2005, 5:57 am

oh hell no....that kid stole my avatar!
:evil:
Image
"In a world without walls and fences, who needs Windows and Gates?"

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 74 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.