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

In summary: ROOT on my comp, I have no clue where to start with that either! In summary, for a beginner, the Apple Developer Tools are a great resource for C++ programming. Although it can be overwhelming for a beginner, Textmate & GCC can be used for simple programs.
  • #1
colin.mcenroe
81
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
  • #2
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.
 
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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.
 
  • #7
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).
 
  • #8
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.
 
  • #9
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.
 

1. What is C++ and why should I learn it?

C++ is a programming language that is widely used in software development. It is a high-level language that allows developers to write efficient and powerful code for various applications. Learning C++ can open up many job opportunities and also improve your problem-solving skills.

2. Can I use C++ on a Mac?

Yes, C++ can be used on a Mac. In fact, Mac OS X comes with a built-in C++ compiler called Clang. You can also use other popular compilers such as GCC or Visual Studio Code to write and run C++ code on a Mac.

3. How do I install C++ on my Mac?

To install C++ on a Mac, you can use a package manager like Homebrew or download and install a compiler like Xcode. Homebrew is a popular choice as it allows for easy management of different versions of C++ compilers and libraries.

4. Are there any good resources for learning C++ on a Mac?

Yes, there are many resources available for learning C++ on a Mac. You can find online tutorials, books, and video courses specifically designed for beginners. Additionally, there are many forums and communities where you can ask questions and get help from experienced developers.

5. What are some basic concepts I should know before learning C++ on a Mac?

Before learning C++ on a Mac, it is helpful to have a basic understanding of programming concepts such as variables, loops, and functions. It is also recommended to have some knowledge of the Mac operating system and its terminal, as you will need to use it for compiling and running C++ code.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
Replies
3
Views
308
  • Programming and Computer Science
Replies
2
Views
1K
  • Computing and Technology
Replies
5
Views
1K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
7
Views
12K
  • Programming and Computer Science
Replies
8
Views
866
  • Programming and Computer Science
Replies
4
Views
15K
  • Programming and Computer Science
Replies
1
Views
232
Back
Top