This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++ versus gcc
- From: LLeweLLyn Reese <llewelly at lifesupport dot shutdown dot com>
- To: "William Trenker" <wtrenker at hotmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 20 Dec 2002 20:37:27 -0800
- Subject: Re: g++ versus gcc
- References: <F57lKy8VBDUfdfdhNzW00000270@hotmail.com>
"William Trenker" <wtrenker@hotmail.com> writes:
> (This has probably been asked a million times, but I did search the
> lists and came up with only sketchy information.)
>
> Today I upgraded my Linux 2.4.19 system from gcc 2.95.3 to gcc 3.2. I
> used this test program:
>
> #include <iostream>
> struct test {
> test(char* m) : msg(m) {};
> char* msg;
> };
> main()
> {
> test* ptest = new test("Hello World");
> cout << ptest->msg << endl;
> };
>
> To build this I used the time-honored: "gcc -o test test.cpp".
>
> The build failed with the compiler complaining that "cout" and "endl"
> weren't declared, and the linker grumbled that it couldn't resolve
> references to "new", "delete", "cout", "basic_ostream" and other
> standard objects.
>
> A search on the mailing lists, and with Google, pointed out that I
> have to explicitly decare namespace "std" -- gcc no longer defaults to
> "std". Further searching suggested that I should be using "g++", not
> "gcc". Doing both these things resulted in my little test program
> building and running without error.
>
> So now, it seems, we need to change all our makefiles, or the relevant
> environment variables, to use "g++" instead of "gcc" for building c++
> files.
No. Change them to use a variable - $(CXX) . Maintainable makefiles do
this anyway.
>
> I would appreciate confirmation that the use of "g++" has officially
> replaced the use of "gcc" for c++ builds.
I'm not an official gcc rep, but even with 2.95.3 I was never able to
get significant C++ prgrams to link without using 'g++'.
However I can't find explicit support for this in their
documentation. Spooky.
[snip]