compiling c++

You need to install the developer tools, which you can get at developer.apple.com
It comes with g++, and a whole lot of other good stuff :p
 
Ive already got the developer tools. Anything special I have to to? Havent tried it yet...just asking.
 
make sure ur man path is set to point to the correct location,

echo $manpath or just type manpath to check where it points to
 
Apple's UNIX implementation (Darwin) is really an update/upgrade of the OpenStep OS from NeXT. For example the usual "gcc" compiler in UNIX is "cc" in Darwin. When you type "man cc" you get a quick 2 or 3 line reference that points you to the developer documentation path & docs. They're html files. Try these docs, and I also believe (not certain) that the "cc" compiler will also compile "C++" code besides "C" and "Objective C" code.
Good luck,
JavaNick
 
ok guys, dont give me up now! But I have some trouble with the "man".

i type "manpath" ----> /usr/share/man
Is this ok?
typing "man cc" only gives me "No manual entry for cc". Is this because my man path isnt set to point to the correct location. What would be the correct location?

As you may notice my UNIX skills arent too big....but Im learning, Im learning!
 
Yeah, my gcc man pages are under /usr/share/man. This is OS X 10.2.3. FWIW, both cc and gcc are symlinks to gcc3. Same goes for the man pages for cc, gcc, g++, etc. All symlinks to gcc3. Exactly what error do you get?
 
The "man" path problem I'm not sure about, but as far as the cc compiler documentation, there is a pdf that comes with the dev tools, you'll find it in Developer/Documentation/Developer Tools/Compiler/Compiler.pdf - There are also html files there which I think (haven't really looked) refer to the same pdf file in chapter form. BTW - I wrote a simple "C" program to check out the compiler, my file compiles OK but I'm having an issue with creating an executable. I'm running 10.1.5; I'll have to do some more research. Good Luck!
 
Darwin has an info page for cc installed. Try "info cc" instead of "man cc".

Hints: use cc for plain C programs and c++ for C++ programs. Both refer to the same GCC 3.1 but the compiler operates in different modes depending on its basename.

Have you already compiled something successfully?
 
"info cc" is working!
Ive just downloaded the latest version of dev tools. Havent had the time to install it yet. Doing it today. No I havent compiled something successfully yet (in Darwin).
 
"info cc" is working!
Ive just downloaded the latest version of dev tools. Havent had the time to install it yet. Doing it today. No I havent compiled something successfully yet (in Darwin).
 
This is a simple example program:

#include <iostream>
int main()
{
std::cout << "Hello World" << endl;
return 0;
}

Save this into a file named hello.c and compile it with:
c++ -o hello hello.c

You will get an executable named "hello" which you can simply execute with:
./hello
(read: dot-slash-"hello")
 
Regarding MANPATH: You need to set the MANPATH environment variable. The easiest way to do so is to edit /etc/profile and add the following two lines:

MANPATH=/usr/share/man:$MANPATH
export MANPATH

(no spaces in the MANPATH= definition!)
 
Ive just successfully compiled "hello world". Just had to add a ".h" after "iostream". Nice. Thanks everyone! You have been very helpfull. Its about -25 degrees celsius in Norway theese days, so its nice to be inside doing some compiling:)
 
Back
Top