C/C++ How do I set up C++ on my Mac for beginners?

  • Thread starter Thread starter colin.mcenroe
  • Start date Start date
  • Tags Tags
    Beginners C++ Mac
AI Thread Summary
To set up C++ on a Mac, users should install Apple Developer Tools, which include GNU command line compilers and debuggers. XCode can be used for programming, but some find it overwhelming and prefer simpler editors like TextWrangler or TextMate. For compiling C++ code, the command line tool GCC is recommended, allowing users to compile and run programs without XCode. ROOT, a tool for variable manipulation in nuclear physics, requires additional setup, but basic programming can be done without needing root access. Overall, beginners are encouraged to explore various editors and utilize terminal commands for a smoother coding experience.
colin.mcenroe
Messages
81
Reaction score
0
Hello,

For my summer project I am going to be writing some C++ code. My computer is a Mac running OS X. I really don't know where to start. I have programmed Java on my Mac previously without too many problems, although I was struggling with setting up XCode. Now with C++, which seems much less user friendly and pretty I have no idea where to start. I need something for boneheads just to set it all up. Once the machine is set up for me to input code, I am fine. Just finding a solid interface that isn't too cold or involved. I am very unfamiliar with all the techie talk and computer science that goes into this stuff, so all the resources are over my head since they seem to assume that I am already programming on my Mac. Also, I need figure out to set up ROOT on my comp, and I have no clue where to start with that either! Any advice is greatly appreciated.

Colin
 
Technology news on Phys.org
Hi.

I'm a fellow Mac user, but I don't program in C++ or Java. However, I can tell you that if you install the Apple Developer Tools, the latest version of which is available for free download from Apple, you're equipped with the GNU command line compilers and debuggers and the whole shebang. You can program from a terminal window or use XCode. On the rare occasions when I need to code in C, I just use gcc from a terminal; I don't understand XCode. Of course you can use any editor you want to use. I like TextWrangler from BareBones (the BBEdit folks). It's completely free and it's a powerful editor.

As long as you're using the account you set up when you got your Mac, there's no need to set up root. The default account has admin privileges and anything that requires anything more can be done using sudo.

Hope that helps.
 
Ok cool. I don't know what the deal with XCode is, that program was making me batty before. I couldn't figure out how to set it up, couldn't compile my Java code, and I finally just gave up and used JJEdit. I would, for this project, like to use a nicer IDE just because I know it is going to be a bit more involved than programming cute hangman games. I will get those developer tools from mac's website. I have seen them before, and in fact I think I did have them installed before, so I will have to look and see if I still have them.

About ROOT, it is actually a tool (http://root.cern.ch/) used for on the fly variable manipulation. I am not sure how to install this framework.
 
If you've installed XCode then the dev tools should be installed too becuase XCode uses gcc for compilation.

Regarding ROOT (as opposed to the superuser account), never heard of it.
 
ROOT is used extensively in nuclear physics, at least from what I gather. I know that it is used by everyone working on the STAR experiment, which is what my project for the summer is related to.
 
ROOT is the name commonly used for the primary account (the one with all administrative power) on many Unix based systems. When you are logged into a non-root account and try to do something that required special permission you often use the superuser command. If you were logged in as root you would not need to use the superuser command.
 
Under Mac OS you never need to log on as 'root' directly. Accounts with administrative privileges can perform Unix-style tasks that require root privileges by using 'sudo [command]' (to run one command at at time) or 'sudo -s' (to launch a shell that has root privileges).
 
You can also use sudo ! if you entered a command that requires permission and you do not want to reenter the command. The "!" simply does the last command, so in effect you execute the previously submitted command with sudo privileges.
 
vckngs7 said:
ROOT is the name commonly used for the primary account (the one with all administrative power) on many Unix based systems. When you are logged into a non-root account and try to do something that required special permission you often use the superuser command. If you were logged in as root you would not need to use the superuser command.

Which is lovely and all, but has little or nothing to do with this thread. The OP was talking about this root, not anything to do with user levels.
 
  • #10
For a beginner, XCode could be a bit overwhelming. For simple programs (using only 1-3 files) I prefer using Textmate & GCC. Although it doesn't have auto-completion it has syntax highlighting and amazing keyboard shortcuts. It's a shareware, but you can try it for free for a month, and it's definitely worth it!

As far as GCC is concerned, you'll have it installed as long as you install the dev tools from your OS X dvd. It's really easy to use and the man pages ("man gcc") have a lot of useful information.

http://macromates.com/
 
  • #13
If you have put the code for a C++ program into the file "somefile.cpp", you can compile and run this quickly without using xcode by typing:

g++ somefile.cpp -o somefile
./somefile

This will be enough to get "hello world" running. You will need to have xcode installed or this will not work, however.
 
Back
Top