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

  • Context: C/C++ 
  • Thread starter Thread starter colin.mcenroe
  • Start date Start date
  • Tags Tags
    Beginners C++ Mac
Click For Summary

Discussion Overview

The discussion revolves around setting up a C++ programming environment on a Mac, particularly for beginners. Participants share their experiences and suggest tools and methods for installation and coding, including the use of XCode, command line tools, and alternative editors. The topic also touches on the installation of the ROOT framework, which is used in nuclear physics.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • Colin expresses difficulty in setting up C++ on his Mac and seeks a user-friendly interface, mentioning previous struggles with XCode.
  • One participant suggests installing Apple Developer Tools, which includes GNU compilers, and mentions using TextWrangler as a preferred editor.
  • Colin indicates a desire for a nicer IDE for his project, noting he has previously installed developer tools.
  • ROOT is introduced as a tool for variable manipulation, with Colin stating its relevance to his summer project in nuclear physics.
  • Another participant clarifies that ROOT is commonly associated with administrative accounts in Unix systems, which leads to some confusion about its context in the discussion.
  • Several participants discuss the use of 'sudo' for executing commands requiring administrative privileges, emphasizing that Mac users do not need to log in as 'root' directly.
  • One participant recommends using Textmate and GCC for simpler programs, while another mentions Notepad++ as a free alternative, although its Mac compatibility is questioned.
  • A participant provides a quick command line method for compiling and running a C++ program without using XCode, highlighting the need for XCode installation for this to work.

Areas of Agreement / Disagreement

Participants express various preferences for development environments and tools, with no consensus on a single best approach. There is confusion regarding the context of ROOT, with differing interpretations of its meaning and relevance to the discussion.

Contextual Notes

Some participants assume familiarity with command line operations and the installation of developer tools, which may not align with Colin's expressed needs as a beginner. The discussion also reflects varying levels of comfort with XCode and alternative programming environments.

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 because 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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 7 ·
Replies
7
Views
13K
Replies
69
Views
11K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
5
Views
8K