Re: help: how to compile c++
- From: Dave Seaman <dseaman@xxxxxxxxxxxx>
- Date: Tue, 30 May 2006 11:06:51 +0000 (UTC)
On Mon, 29 May 2006 21:51:43 -0600, Tom Harrington wrote:
In article <carl-09BD7F.20043629052006@xxxxxxxxxxxxxxxxxxxxxxxx>,
Carl Witthoft <carl@xxxxxxxxxxxx> wrote:
HI -- I'm well experienced in programming under unix, but haven't ever
played w/ c++. I have successfully compiled c programs on OSX (using
gcc of course). The problem is my child needs to write stuff in c++
for a professor. Her first try crashed, which is to say gcc didn't
like it.
So: can anyone tell me what I need to set up? Should gcc be able to
handle c++, or do I need to set some switches, or download different
libraries, etc?
Well, I normally don't say it, but since you're someone experienced in
programming on Unix, I think "RTFM" might be in order. "man gcc" is a
great place to start. This kind of thing is the same on Mac OS X as on
any other Unix box.
GCC normally uses the filename extension to decide what language is
likely to be in the file. File "foo.c" will normally be assumed to be C
rather than C++, but "foo.cpp" would be assumed to be C++.
There's also "g++", which is just gcc but with the default language set
to C++ rather than C. Replace "gcc" with "g++" and you may be set.
But note that if you compile and link in separate steps (as you would
likely do if using make), then the link step should be performed with g++
in order to get the right libraries. Just depending on the suffix is not
going to help you here. It's better to use g++ throughout when compiling
and linking C++ code.
Finally of course there's gcc's "-x" option, which allows you to specify
any supported language you like regardless of anything else. Name your
C++ file "foo.java" if you like, and the right "-x" flag will make it
work.
--
Dave Seaman
U.S. Court of Appeals to review three issues
concerning case of Mumia Abu-Jamal.
<http://www.mumia2000.org/>
.
- References:
- help: how to compile c++
- From: Carl Witthoft
- Re: help: how to compile c++
- From: Tom Harrington
- help: how to compile c++
- Prev by Date: Re: why this simple bash script doesn't run on my G5 OS X Tiger?
- Next by Date: Re: help: how to compile c++
- Previous by thread: Re: help: how to compile c++
- Next by thread: Re: help: how to compile c++
- Index(es):
Relevant Pages
|