This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems compiing with g++ / c++


"Anthony R. Mattke" <tonhe at adelphia dot net> writes:

> I should've specified.. this problem is when using gcc v2.95.3
> i have tried using iostream instead of iostream.h and both fail..

Then I was mistaken. Sorry.

> 
> Here are some examples.. 
> g++ -v
> Reading specs from /usr/lib/gcc-lib/i386-slackware-linux/2.95.3/specs
> gcc version 2.95.3 20010315 (release)
> tonhe at hiku:~$ cat hello.cpp
> #include <iostream.h>
>  
> int main(int argc, char** argv)
> {
> cout << "HELLO WORLD!" << endl;
> return 0;
> }
> tonhe at hiku:~$ g++ -o hello hello.cpp
> hello.cpp:1: iostream.h: No such file or directory
> 
> tonhe at hiku:~$ gcc -o hello hello.cpp -I/usr/include/g++-3
> /tmp/ccHh480W.o: In function `main':
> /tmp/ccHh480W.o(.text+0xa): undefined reference to `endl(ostream &)'
> /tmp/ccHh480W.o(.text+0x17): undefined reference to `cout'
> /tmp/ccHh480W.o(.text+0x1c): undefined reference to
> `ostream::operator<<(char const *)'
> /tmp/ccHh480W.o(.text+0x27): undefined reference to
> `ostream::operator<<(ostream &(ostream &))'
> collect2: ld returned 1 exit status
> 
> tonhe at hiku:~$ gcc -o hello hello.cpp -I/usr/include/g++-3 -L
> /usr/lib/gcc-lib/i386-slackware-linux/2.95.3/ -lstdc++
> tonhe at hiku:~$ ldd hello
>         libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3
> (0x40026000)
>         libc.so.6 => /lib/libc.so.6 (0x40070000)
>         libm.so.6 => /lib/libm.so.6 (0x40181000)
>         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> tonhe at hiku:~$ ./hello
> HELLO WORLD!
> 
> So, how can i fix this ?

I don't know. Add -v to your command line, for both the g++ and the
    gcc tests; that will make gcc and g++ spit out
    more output, such as its version, and where it is looking for
    include files.

> I thought about building a wrapper script to help this problem along..
> but i want to find the _REAL_ root of the problem..

I suspect you have a broken gcc install.

If you are reasonably skilled with slackware's install tools, consider
    trying to use them to uninstall the g++ packages, including the
    libraries.

Also, since your c compiler appears to work, you might try building
    gcc from source, (using a --prefix other than /usr/ or /usr/local,
    of course) and using that.

Just speculating.
    

> and for proof the iostream - the .h dosent work aswell.. 
> tonhe at hiku:~$ cat hello.cpp
> #include <iostream>
>  
> int main(int argc, char** argv)
> {
> cout << "HELLO WORLD!" << endl;
> return 0;
> }
> tonhe at hiku:~$ g++ -o hello hello.cpp
> hello.cpp:1: iostream: No such file or directory
[snip]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]