Compiling c++ in terminal

I just upgraded to Mac OS X 10.6.7 and now using the command

g++ xxx.cpp -o xxx

to compile isn't working.

What do I do?
Are you getting an error message?

Do you have gcc installed? Do you have g++ appropriately aliased to the relevant gcc command (depending on setup, this one is)?

Do you have g++ on your path? What output do you get for "which gcc" and "which g++"?
Last edited on
It says "command not found".

Is it installed? When I search gcc through spotlight I see a gcc (MacOSX.10.5.sdk). I assumed that it was installed automatically with the upgrade. I did install Xcode before I ever started compiling perhaps gcc is included with that?

I searched for gcc 10.6 on apple.com and found nothing.

When I compile it is from within the directory of the file I am trying to compile.


I just tried "which g++" and it seemed to work but when I tried to run the program after

which g++ xxx.cpp -o xxx
./xxx
(No such file or directory).

Should I updated to the latest version of Xcode?
Hello,

mschott21, please post the answer to the following commands (go to the directory with your cpp file):
1) g++
2) g++ -c xxx.cpp
3) g++ -o executable.out xxx.o
4) ./executable.out

I have Debian linux and my outputs are like soȘ
1) g++: no input files
2) nothing
3) nothing
4) the output of my program.
1. command not found
2. command not found
3. command not found
4. does not exist

Is there an updated version of gcc that I need to install? If so I can't find it on developer.apple.com unless its in the Xcode 4 package which costs $$$. I am stuck.
Last edited on
I'm glad you got your program working.
In linux, witch command returns the path to the executable, maybe try to check if the path console variable is set corectly. In bash I would do " echo $PATH$".
I thought it was working but I really was just running the executable file i created before. I really don't know how to create an executable now. I'll try to check the path but I don't know how to fix anything and I am not confident in my ability to recognize an error.
Last edited on
It sounds like you simply haven't got it installed, or it's not on your path (i.e. cannot be found when you try to run it).
And what would be the correct path?
(home)/documents/c++_files is my directory location
On my system, gcc lives in /usr/bin/

I've no idea about yours.
Topic archived. No new replies allowed.