LinuxQuestions.org
Visit Jeremy's Blog.
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 04-01-2003, 03:11 PM   #1
the_styler
Member
 
Registered: Apr 2003
Distribution: RedHat 8.0
Posts: 30

Rep: Reputation: 15
GCC doesn't find the Standard-Library


When I try to compile a C++ programm on my Redhat 8.0 system using the gcc, I always get plenty of errors although I'm quite sure that my program i correct.
It seems to me that the gcc doesn't find the Standard-Library, but I'm really a Linux Newbie.
Any help is welcomed & thanx in advance
styler.

My Program code:
Code:
// comment
#include <iostream>

int main()
{
	std::cout <<"Hello world!\n";
	return 0;
}
A "Screenshot" from the konsole:

Code:
[root@localhost root]# gcc /home/my_dir/dev/test.cpp -o/home/my_dir/dev/test
/tmp/ccpQkfQU.o: In function `main':
/tmp/ccpQkfQU.o(.text+0x19): undefined reference to `std::cout'
/tmp/ccpQkfQU.o(.text+0x1e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccpQkfQU.o: In function `__static_initialization_and_destruction_0(int, int)':
/tmp/ccpQkfQU.o(.text+0x4a): undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccpQkfQU.o: In function `__tcf_0':
/tmp/ccpQkfQU.o(.text+0x79): undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccpQkfQU.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
 
Old 04-01-2003, 03:58 PM   #2
bahamat
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 158

Rep: Reputation: 30
#include <iostream.h>
 
Old 04-02-2003, 03:00 AM   #3
the_styler
Member
 
Registered: Apr 2003
Distribution: RedHat 8.0
Posts: 30

Original Poster
Rep: Reputation: 15
Sorry, but that only gives me an additional "deprecated-warning". Any other suggestions?
Thanx for your help,
styler

warning: #warning This fi
le includes at least one deprecated or antiquated header. Please consider using
one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples in
clude substituting the <X> header for the <X.h> header for C++ includes, or <sst
ream> instead of the deprecated header <strstream.h>. To disable this warning us
e -Wno-deprecated.
 
Old 04-02-2003, 12:22 PM   #4
bahamat
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 158

Rep: Reputation: 30
Well, I would say that you should

Quote:
consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>.
Hope that clears things up.
 
Old 04-02-2003, 02:53 PM   #5
pilgrim22
LQ Newbie
 
Registered: Mar 2003
Location: TX
Distribution: SuSE/RedHat
Posts: 5

Rep: Reputation: 0
try the command "g++" instead of "gcc". The linker thinks you are linking a C program. g++ tells it it's a C++ program.

p22
 
Old 04-03-2003, 09:34 AM   #6
the_styler
Member
 
Registered: Apr 2003
Distribution: RedHat 8.0
Posts: 30

Original Poster
Rep: Reputation: 15
wow thanx!
when i use g++ instead gcc i get no errors! unfortunately i still have a problem...
all the g++ does is to create a file called "out.a". then i want to run my program by typing "out.a" in the konsole. in return i get an error from the konsole:
"bash: a.out: command not found"

thanx again for your support,
styler
 
Old 04-03-2003, 11:48 AM   #7
pilgrim22
LQ Newbie
 
Registered: Mar 2003
Location: TX
Distribution: SuSE/RedHat
Posts: 5

Rep: Reputation: 0
I assume you meant "a.out" for the output file... However if you specfied -o option to g++, you should not get an a.out, but the name specified!

To run the file, assuming you are in the same directory as your file, type "./a.out" (without quotes). If you are in a different directory, replace the dot with the directory that a.out is in.

hope this helps...
 
Old 04-03-2003, 12:07 PM   #8
the_styler
Member
 
Registered: Apr 2003
Distribution: RedHat 8.0
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks, it did help!
 
Old 07-24-2003, 05:56 AM   #9
devgirl
LQ Newbie
 
Registered: Jul 2003
Posts: 2

Rep: Reputation: 0
Talking

Just wanted to say that I have spent hours and hours trying to solve this same problem and after seeing this posting it all works - thank you so much - i was at my wits end!
 
Old 07-24-2003, 07:37 AM   #10
pilgrim22
LQ Newbie
 
Registered: Mar 2003
Location: TX
Distribution: SuSE/RedHat
Posts: 5

Rep: Reputation: 0
You're all welcome! Glad to be of help!
 
Old 08-03-2003, 09:32 PM   #11
mayagenesis
LQ Newbie
 
Registered: Jul 2003
Posts: 6

Rep: Reputation: 0
thanks to the solution, I had the same problem and it is solved now.
 
Old 01-15-2004, 08:09 PM   #12
SunnySky
LQ Newbie
 
Registered: Jan 2004
Posts: 1

Rep: Reputation: 0
Another huge thank you. I also spent several hours trying to figure this out.

Cheers,

SunnySky
 
  


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
'sort' fn. in C++ standard library frankie_DJ Programming 2 12-14-2004 02:27 PM
Standard C and C++ Library Documentation elluva Programming 12 10-25-2004 04:28 AM
standard library for graphics jpostma Programming 3 07-19-2004 06:13 AM
C++ standard library. Thetargos Programming 8 10-09-2003 03:01 PM
gcc cannot find -lc library DarkDrive Linux - Software 1 08-08-2003 05:05 PM


All times are GMT -5. The time now is 06:12 AM.

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