Re: c++ hello world help
Once upon a time Kevin Mark said...
> Hi D-u,
> I'm trying to get gcc to compile some basic c++ programs and I'm running
> into some probably some really basic setup mistakes.
> gcc works with C programs.
> but c++ programs cant find the libs.
> =====================================================
>
> ~/cpluscplus\% g++ page23.cpp
> (this compiles)
> ===========================================================
> but
> ==========================================================
> ~/cpluscplus\% gcc page23.cpp
> collect2: ld returned 1 exit status
> -----------------------------------------------------------
> I installed libstdc++ and gcc versions 2.95,3.2,3.3
> WHAT FILES DO I HAVE TO CONFIGURE OR INSTALL!
You did it right the first time. If you want to compile (link) a C++
program, you use g++. gcc is used to compile (link) C programs.
gcc will call the C++ compiler to turn your .cpp file into a .o file,
but when it runs the linker, it links as though you have a C program. It
does this because you told it to (by running gcc, not g++). If you call
it as g++ it will link in the C++ libraries.
Reply to: