C++ In Unix
September 5, 2002 7:42PM
edited January 2014
Is there any way to program in C++ in the terminal and then compile from there? I want to use C++ but not Visual C++. Is there any way to do this?
Or if there isn't, are there any non visual C++ programming environments for OS X with compilers?
Reply 1 of 2
September 5, 2002 7:51PM
Visual C++ is a Microsoft environment. It's not available in any form on OS X.
You can write vanilla C++ in Project Builder (or CodeWarrior, for that matter) or fire up an editor (GUI or terminal), save and run 'cc <filename.cpp>' on the command line to compile, and './a.out' to run. That's perfectly useful for light work; for more, you want to read the man pages for cc (which is just an alias for gcc) or use Project Builder (which is built around gcc).
If you want to go 100% command line for whatever reason, the available editors are pico, emacs and vi. More are available for download. I use pico and vi when I bother with a command line editor, but since I'm straying into religion here I'll just recommend that you try them all out and pick one. pico is the easiest to use by far, and also the least powerful - but it's fine for light coding. However, I'd recommend downloading BBEdit Lite if you don't have it already, and using that.
[ 09-05-2002: Message edited by: Amorph ]</p>
Reply 2 of 2
September 5, 2002 8:47PM
To be slightly more accurate, to invoke the C++ compiler, the command is "c++" or "g++". "cc" or "gcc" gets you the C compiler. If you use the C compiler on C++ code, the code will compile, but it will be linked with the wrong libraries.