Hi Michael.
The c++ compiler would be called g++, which is also the command to
invoke it.

One correction though. If you do
> gcc csimple.c -o csimple.o
(or what you will probably do with c++)
> g++ cppsimple.cpp -o cppsimple
it actually compiles directly into executable code, bypassing generation
of an object file. That is this command actually does two things - it
compiles your source code into object code and then generates an
executable out of the object file. The first part is called
"compilation" and the second is called "linking".
If you do (note the "-c" flag)
> gcc -c csimple.c -o csimple.o
it will only generate an object file, which you can not execute. You can
perform linking with it by doing the following:
> gcc csimple.o -o csimple

Usually, when your program is short then you put all code in one file
and compile it the way you did with your c program. Except without
giving the output file ".o" extension, because even though in Linux
(unix) file extensions don't mean as much as they do in, say, Windows,
it's a convention that ".o" files are object files generated by a compiler.
Compiling your source files into object code will come in handy when
your programs grow in size and you will want to split your programs in
multiple source files and compile them separately. But that's going to
be a little later :-)

Cheers,
Victor Prosolin.



Michael John Walters wrote:
> Hello All,
> 
> I know that I have a C compiler on my system because I wrote a simple C
> programme called csimple.c and used the command, gcc csimple.c -o
> csimple.o and got the object code file csimple.o and when I did the
> command ./csimple.o the programme worked beautifully giving me exactly
> the result I wanted.
> 
> However, when I tried to compile a simple C++ program with gcc I got a
> number of compilation errors indicating that the gcc compiler is not
> also a C++ compiler.
> 
> I was wondering what the C++ compiler is called and whether it is easy
> to install. If I knew the name of the C++ compiler I could even do an
> aptitude search <C++ compiler> where <C++ compiler> is the correct name
> of the C++ compiler and I could find out whether it is on my system or
> not. If it is on my system but not yet installed, it should be easy to
> install.
> 
> I would like to install the C++ compiler so that I could go through a  
> C++ programming book that my brother gave me. I see that the book my
> brother gave me has a lot of programmes I want to write given as
> examples. I would then modify my programmes to do exactly what I want,
> And the changes from the examples in the book are very minor. The book
> my brother gave me is "How to think like a computer scientist" by Allen
> B. Downey C++ Version, First Edition.
> 
> So the two things I would like to find out are "What is the name of the
> gnome C++ compiler?" and "What is the command to compile a C++ program?"
> 
> Once my C++ program called cplusplussimple.cpp is compiled successfully
> as an object code file called cplusplussimple.o the
> command ./cplusplusimple.o should run it, if I am not mistaken.
> 
> Please comment on my ramblings.
> 
> Regards,
> 
> Michael Walters - tier two member
> 
> 
> _______________________________________________
> clug-talk mailing list
> [email protected]
> http://clug.ca/mailman/listinfo/clug-talk_clug.ca
> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
> **Please remove these lines when replying

begin:vcard
fn:Victor Prosolin
n:Prosolin;Victor
org:University of Calgary;Department of Physics and Astronomy
adr;dom:;;SB628
title:PhD Candidate
tel;work:+1-403-220-6340
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

Reply via email to