This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problems compiing with g++ / c++
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..
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 thought about building a wrapper script to help this problem along..
but i want to find the _REAL_ root of the problem..
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
Thanks for all the help....
On Mon, 2003-03-17 at 22:10, LLeweLLyn Reese wrote:
> "Anthony R. Mattke" <tonhe at adelphia dot net> writes:
>
> > I have a older slack 8 install on my desktop that has been giving me
> > trouble for a couple months.
> >
> > Neithier c++ or g++ can seem to find their own headers anymore in
> > /usr/include/g++-3 Does anyone have any clue why this would be ?
>
> The headers provided in <prefix>/include/g++-3 where an interim
> solution to the fact that gcc did not (during the gcc 2.9
> timeframe) have an implementation of the standard C++ library.
>
> Starting with gcc 3.0, gcc now provides an implementation of the
> standard C++ library. It is however provided in a different
> (version-specific) directory.
>
> The g++-3 directory is not used by any gcc 3.0 or greater.
>
> >
> > Here is a partial output from a failed build of mozilla from last
> > night..
> >
> > Thanks in advance for the help.
> >
> > g++ -o TestCOMPtr.o -c -DOSTYPE=\"Linux2.4\" -DOSARCH=\"Linux\" -DOJI
> > -I./../ds
> > -I./services -I../../dist/include/string -I../../dist/include/xpcom
> > -I../../dist/include -I/root/mozilla/dist/include/nspr
> > -I/usr/X11R6/include -fPIC -I/usr/X11R6/include -fno-rtti
> > -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align
> > -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -pedantic
> > -Wno-long-long -pthread -pipe -DDEBUG -D_DEBUG -DDEBUG_root -DTRACING
> > -g -fno-inline -I/usr/X11R6/include -DMOZILLA_CLIENT -include
> > ../../mozilla-config.h -Wp,-MD,.deps/TestCOMPtr.pp TestCOMPtr.cpp
> > TestCOMPtr.cpp:39: iostream.h: No such file or directory
>
> iostream.h is not part of standard C++. You must complain to the
> mozilla people; they must use <iostream> instead.
>
> For the near-term, install gcc-2.95.3 alongside of your newer
> compiler, and projects which cannot be built with the newer
> compiler should be built with the old one.
>
> > TestCOMPtr.cpp: In method `test_message::test_message()':
> > TestCOMPtr.cpp:104: `cout' undeclared (first use this function)
> > TestCOMPtr.cpp:104: (Each undeclared identifier is reported only once
> > TestCOMPtr.cpp:104: for each function it appears in.)
> > TestCOMPtr.cpp:104: `endl' undeclared (first use this function)
>
> cout and endl are in the std namespace, and proper qualifiers, using
> directives, or using declarations are required.
>
> gcc-2.95.x accepted:
>
> #include<iostream>
> using std::cout;
> using std::endl;
>
> along with older, pre-standard constructs in order to provide
> developers with time to migrate. But newer gccs require the above,
> and no loonger accept pre-standard stuff.
>
> > make[3]: *** [TestCOMPtr.o] Error 1
> > make[3]: Leaving directory `/server/root/mozilla/xpcom/tests'
> > make[2]: *** [libs] Error 2
> > make[2]: Leaving directory `/server/root/mozilla/xpcom'
> > make[1]: *** [tier_2] Error 2
> > make[1]: Leaving directory `/server/root/mozilla'
> > make: *** [default] Error 2
--
Anthony R. Mattke <tonhe at adelphia dot net>