codenamejupiterx
codenamejupiterx

Reputation: 1619

how do you use the terminal on mac os 10 to write and compile c++ code?

how do you use the terminal on mac os 10 to write and compile c++ code? I have a power mac with the power pc chip/with leopard.

Upvotes: 2

Views: 9072

Answers (2)

Potatoswatter
Potatoswatter

Reputation: 137830

The simplest text editor included with Mac is nano. It's pretty self-explanatory. Once you've saved the source file, just run g++ my_source_file.cpp -o my_program_name to compile.

However, I recommend using the XCode IDE. The old version 3.2 is a 600 MB download, or the new 4.0 is $5. Even though it's not the best, you will have a much better time with it than learning the command line from scratch. And if you install the compiler using Apple's installer in the first place, you already have it.

Upvotes: 1

icktoofay
icktoofay

Reputation: 129001

First, make sure you've got Apple's developer tools installed. They may be on your Mac OS X install disk as well, if you don't feel like downloading. (although you may get an older version) After that, cd to where your code is and do something similar to this:

g++ -o my_executable my_cpp_code.cpp

You can then run it like this:

./my_executable

Upvotes: 5

Related Questions