Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C++ Compiler Command on the Command Line?

C++ Compiler Command on the Command Line?
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 1999
Location: NY
Status: Offline
Reply With Quote
Jun 6, 2001, 11:51 AM
 
Newbie. I just wanted to compile a simple C++ program (using EMACS as the editor) on the command line. I know that "cc" is the compiler for C programs. Also, does anyone know how I would go about getting the "gcc" compiler for MacOS X?

Thanks in advance.
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Jun 6, 2001, 12:50 PM
 
If you installed the dev tools, you have gcc. cc is just a link to gcc.[/LIST]
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Jun 6, 2001, 12:55 PM
 
Whoops, I was wrong. cc IS gcc, only renamed.

Typing cc -v gives you:

<font face = "courier">Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
Apple Computer, Inc. version gcc-926, based on gcc version 2.95.2 19991024 (release)</font>
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Jun 6, 2001, 07:08 PM
 
The command to compile a c++ program is just c++. For example:

c++ mySource.cpp

HTH.

-Peter
     
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Jun 7, 2001, 07:10 AM
 
I'm pretty sure that if you call your source file foo.cpp, then simply
calling gcc/cc will do the Right Thing. GCC's frontend figures out
what it's being fed, or is it .c++ (?), check man page.

The C and C++ compilers are integrated. Both process input
files through one or more of four stages: preprocessing,
compilation, assembly, and linking. Source filename suf-
fixes identify the source language, but which name you use
for the compiler governs default assumptions:

gcc assumes preprocessed (.i) files are C and assumes C
style linking.

g++ assumes preprocessed (.i) files are C++ and assumes C++
style linking.

Suffixes of source file names indicate the language and kind
of processing to be done:

.c C source; preprocess, compile, assemble
.C C++ source; preprocess, compile, assemble
.cc C++ source; preprocess, compile, assemble
.cxx C++ source; preprocess, compile, assemble
.m Objective-C source; preprocess, compile, assemble

[ 06-07-2001: Message edited by: howardm4 ]
     
Mac Elite
Join Date: Jun 2001
Location: Dundee, Scotland
Status: Offline
Reply With Quote
Jun 8, 2001, 08:36 AM
 
quick tip:

to compile a C file called prog.c (perhaps with a header prog.h) into an executable called prog just type make prog.

--s.

[ 06-08-2001: Message edited by: sambeau ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:48 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2