PDA

View Full Version : simple "hello" program won't complile


caporal
1st August 2004, 04:15 PM
ok....I have seen plenty of posts describing similar problems, but have yet to find a solution. I'm trying to compile a simple program using the g++ compiler.

#include <iostream>

int main()
{
std::cout << "hello" << std::endl;
}


The output from the compile is:

In file included from /usr/include/c++/3.3.3/iosfwd:46,
from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/c++locale.h:41:19: clocale: No such file or directory
In file included from /usr/include/c++/3.3.3/iosfwd:46,
from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/c++locale.h:53: error: `uselocale
' was not declared in this scope
In file included from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/iosfwd:47:53: cctype: No such file or directory
In file included from /usr/include/c++/3.3.3/memory:54,
from /usr/include/c++/3.3.3/string:48,
from /usr/include/c++/3.3.3/bits/locale_classes.h:47,
from /usr/include/c++/3.3.3/bits/ios_base.h:47,
from /usr/include/c++/3.3.3/ios:49,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/stl_algobase.h:66:19: climits: No such file or directory
In file included from /usr/include/c++/3.3.3/bits/locale_facets.h:166,
from /usr/include/c++/3.3.3/bits/basic_ios.h:44,
from /usr/include/c++/3.3.3/ios:51,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:44: error: `_ISupper
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:45: error: `_ISlower
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:46: error: `_ISalpha
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:47: error: `_ISdigit
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:48: error: `
_ISxdigit' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:49: error: `_ISspace
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:50: error: `_ISprint
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:51: error: `_ISgraph
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:52: error: `_IScntrl
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:53: error: `_ISpunct
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:54: error: `_ISalnum
' was not declared in this scope
In file included from /usr/include/c++/3.3.3/locale:47,
from /usr/include/c++/3.3.3/bits/ostream.tcc:37,
from /usr/include/c++/3.3.3/ostream:535,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/locale_facets.tcc:38:18: cerrno: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:39:50: clocale: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:41:44: cmath: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:42:47: cctype: No such file or directory


I'm no "c" programming guru, not even a novice, but my 10 year old son got this to compile this week at tech camp (sadly on a M$ box).

What gives with my C++ installation?

My apologies is this is posted to the wrong forum

/jcc

Varkk
1st August 2004, 04:48 PM
what command are you using to compile it? I get some errors if I type gcc hello.c, if I use g++ hello.c it compiles fine and runs as you would expet (This is on a Redhat 9 box with gcc version 3.2.2

caporal
1st August 2004, 05:43 PM
g++ -c hello.cpp

I'm using gcc-3.3.3-7 on a fedora core 2 installation.

ghaefb
1st August 2004, 09:54 PM
main function should return 0;

int main()
{
std::cout << "hello" << std::endl;
return 0;
}

compile like this: g++ hello.cpp -o hello -Wall -O2

caporal
1st August 2004, 11:07 PM
Still not able to compile error free........which compiler version are you running?
I've recompiled the kernel (2.6.6-1.435.2.3) that came via up2date to enable ntfs support, etc. The HW is a presario 2100 (amd athlon) and has been running very well on FC2.


$ g++ hello.cpp -o hello -Wall -O2

In file included from /usr/include/c++/3.3.3/iosfwd:46,
from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/c++locale.h:41:19: clocale: No such file or directory In file included from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/iosfwd:47:53: cctype: No such file or directory
In file included from /usr/include/c++/3.3.3/memory:54,
from /usr/include/c++/3.3.3/string:48,
from /usr/include/c++/3.3.3/bits/locale_classes.h:47,
from /usr/include/c++/3.3.3/bits/ios_base.h:47,
from /usr/include/c++/3.3.3/ios:49,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/stl_algobase.h:66:19: climits: No such file or directory
In file included from /usr/include/c++/3.3.3/bits/locale_facets.h:166,
from /usr/include/c++/3.3.3/bits/basic_ios.h:44,
from /usr/include/c++/3.3.3/ios:51,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:44: error: `_ISupper
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:45: error: `_ISlower
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:46: error: `_ISalpha
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:47: error: `_ISdigit
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:48: error: `
_ISxdigit' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:49: error: `_ISspace
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:50: error: `_ISprint
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:51: error: `_ISgraph
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:52: error: `_IScntrl
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:53: error: `_ISpunct
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:54: error: `_ISalnum
' was not declared in this scope
In file included from /usr/include/c++/3.3.3/locale:47,
from /usr/include/c++/3.3.3/bits/ostream.tcc:37,
from /usr/include/c++/3.3.3/ostream:535,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/locale_facets.tcc:38:18: cerrno: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:39:50: clocale: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:41:44: cmath: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:42:47: cctype: No such file or directory
[johnc@Sting John]$ ls
a4reset_files hello.cpp~ Resumes
a4reset.html jc_signature.html snMakefile
BJPstore.pl_files Kingfish Product Requirements 1_1.doc Taxes
BJPstore.pl.html perim.c~ Travel
build perim.cpp
hello.cpp programming
[johnc@Sting John]$ g++ hello.cpp -o hello -Wall -O2
In file included from /usr/include/c++/3.3.3/iosfwd:46,
from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/c++locale.h:41:19: clocale: No such file or directory
In file included from /usr/include/c++/3.3.3/ios:44,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/iosfwd:47:53: cctype: No such file or directory
In file included from /usr/include/c++/3.3.3/memory:54,
from /usr/include/c++/3.3.3/string:48,
from /usr/include/c++/3.3.3/bits/locale_classes.h:47,
from /usr/include/c++/3.3.3/bits/ios_base.h:47,
from /usr/include/c++/3.3.3/ios:49,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/stl_algobase.h:66:19: climits: No such file or directory
In file included from /usr/include/c++/3.3.3/bits/locale_facets.h:166,
from /usr/include/c++/3.3.3/bits/basic_ios.h:44,
from /usr/include/c++/3.3.3/ios:51,
from /usr/include/c++/3.3.3/ostream:45,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:44: error: `_ISupper
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:45: error: `_ISlower
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:46: error: `_ISalpha
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:47: error: `_ISdigit
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:48: error: `
_ISxdigit' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:49: error: `_ISspace
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:50: error: `_ISprint
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:51: error: `_ISgraph
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:52: error: `_IScntrl
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:53: error: `_ISpunct
' was not declared in this scope
/usr/include/c++/3.3.3/i386-redhat-linux/bits/ctype_base.h:54: error: `_ISalnum
' was not declared in this scope
In file included from /usr/include/c++/3.3.3/locale:47,
from /usr/include/c++/3.3.3/bits/ostream.tcc:37,
from /usr/include/c++/3.3.3/ostream:535,
from /usr/include/c++/3.3.3/iostream:45,
from hello.cpp:1:
/usr/include/c++/3.3.3/bits/locale_facets.tcc:38:18: cerrno: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:39:50: clocale: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:41:44: cmath: No such file or directory
/usr/include/c++/3.3.3/bits/locale_facets.tcc:42:47: cctype: No such file or directory

Ug
1st August 2004, 11:07 PM
I thought in C this did it it: #include <iostream.h>

int main( void )
{
printf("Hello World!,\n");
return 0;
}

caporal
2nd August 2004, 05:08 AM
I see that there are two folders in /usr/include that have similar files:

g++-3 and c++

It looks like not all files that the compiler is complaining about are in c++, yet that's the folder the compiler is accessing.

I have a gut feeling that my "gcc" installtion is not right, but am at a loss as to where to go from here.

Bana
2nd August 2004, 07:28 AM
This is the darndest thing, it works for me so I would have to guess that something is wrong with your setup. Perhaps you could (dare I say it) reinstall? Just use yum's group package functionality to erase all compiler.

caporal
3rd August 2004, 01:12 AM
That did it! I took your advice and using yum did a remove of the compiler and then an install. I had to also reinstall the kernel source tree. I can now compile c sources!

Thanks to everyone who took the time and patience to help me thru this.
Hats off to all of you!

Bana
3rd August 2004, 08:08 AM
I am just glad that you can finally show your son that Linux can print Hello World to the console as well as Windows :D