LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   GCC doesn't find the Standard-Library (https://www.linuxquestions.org/questions/linux-software-2/gcc-doesnt-find-the-standard-library-52915/)

the_styler 04-01-2003 03:11 PM

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


bahamat 04-01-2003 03:58 PM

#include <iostream.h>

the_styler 04-02-2003 03:00 AM

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.

bahamat 04-02-2003 12:22 PM

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.

pilgrim22 04-02-2003 02:53 PM

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

the_styler 04-03-2003 09:34 AM

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
:newbie:

pilgrim22 04-03-2003 11:48 AM

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! :confused:

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...

the_styler 04-03-2003 12:07 PM

Thanks, it did help!

devgirl 07-24-2003 05:56 AM

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!

pilgrim22 07-24-2003 07:37 AM

You're all welcome! Glad to be of help! :)

mayagenesis 08-03-2003 09:32 PM

thanks to the solution, I had the same problem and it is solved now.

SunnySky 01-15-2004 08:09 PM

Another huge thank you. I also spent several hours trying to figure this out.

Cheers,

SunnySky


All times are GMT -5. The time now is 01:03 PM.