Register to reply

C++ on a Mac for beginners?

by colin.mcenroe
Tags: beginners
Share this thread:
colin.mcenroe
#1
May14-07, 07:56 PM
P: 81
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
Phys.Org News Partner Science news on Phys.org
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker
heafnerj
#2
May14-07, 08:43 PM
P: 48
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.
colin.mcenroe
#3
May15-07, 01:03 PM
P: 81
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.

heafnerj
#4
May15-07, 02:06 PM
P: 48
C++ on a Mac for beginners?

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.
colin.mcenroe
#5
May17-07, 12:53 PM
P: 81
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.
vckngs7
#6
Oct17-09, 01:14 PM
P: 2
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.
jtbell
#7
Oct17-09, 05:36 PM
Mentor
jtbell's Avatar
P: 11,782
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).
vckngs7
#8
Oct17-09, 05:39 PM
P: 2
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.
shoehorn
#9
Oct17-09, 06:46 PM
P: 448
Quote Quote by vckngs7 View Post
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.
Alexstre
#10
Oct18-09, 08:12 PM
P: 19
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/
rootX
#11
Oct18-09, 08:23 PM
rootX's Avatar
P: 1,294
^
notepad++ is free
http://notepad-plus.sourceforge.net/uk/site.htm
Alexstre
#12
Oct18-09, 08:28 PM
P: 19
Quote Quote by rootX View Post
I wasn't aware of a Mac version of Notepad++! If so then it'd be worth checking it out then
Coin
#13
Oct19-09, 04:02 PM
P: 587
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.


Register to reply

Related Discussions
Calculus for beginners Academic Guidance 16
Fortran for beginners Computing & Technology 12
Brother got his first teloscope Astronomy & Astrophysics 4
A beginners question Beyond the Standard Model 15
Books for beginners General Physics 0