Problem with broken complier in Linux Fedora Core 1

  • Supasiri
  • Born
  • Born
  • Supasiri
  • Posts: 4
  • Loc: US

Post 3+ Months Ago


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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • pifua
  • Newbie
  • Newbie
  • pifua
  • Posts: 10

Post 3+ Months Ago

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

Post 3+ Months Ago

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
  • Supasiri
  • Posts: 4
  • Loc: US

Post 3+ Months Ago

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
  • Posts: 24

Post 3+ Months Ago

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
  • tdopsdarock
  • Posts: 1

Post 3+ Months Ago

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
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

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
  • shut up
  • Born
  • Born
  • User avatar
  • Posts: 2
  • Loc: china

Post 3+ Months Ago

I uesd to write :
gcc -ggdb3 -o xxx /path/xxx.c
./xxx.c
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

oh hell no....that kid stole my avatar!
:evil:

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 87 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.