Compile commands - Chapter 25 example, for example

Jonathan Wakely
Sat Dec 17 23:04:00 GMT 2011

On 17 December 2011 22:29, Matthew D. Gutchess wrote:
> Hi,
>    I just started using (2011 Dec 16) the gcc compiler which was included with Ubuntu 11.04.  Can you include compile commands in your manual?  Compiling the example in Chapter 25 on output buffers, which I called "outbuf1_Josuttis_text.cpp", produced lots of error messages, included below.  Because this program is made for gcc and listed on the gcc website, I figure that I need a more complex "gcc" command with specific references to the locations of libraries.

You should use g++ to compile C++ programs instead of gcc, as
explained in the manual under "Compiling C++ Programs"

"However, the use of gcc does not add the C++ library. g++ is a
program that calls GCC and treats `.c', `.h' and `.i' files as C++
source files instead of C source files unless -x is used, and
automatically specifies linking against the C++ library."

More information about the Gcc-help mailing list