Text editor Mac getting started.

Just started using a mac and I want to use text editor to write my C++ programs. How do I run a program using terminal?
Where do I need to save the program?
Does it need to have the .cpp file type?

I've used smultron on a mac and that was OK

http://www.peterborgapps.com/smultron/

If you give it the .cpp type then smultron will syntax highlight it and other stuff might be easier too

Just save the .cpp file where you are working

Open the terminal. you need to know basic unix command line stuff (cd = change directory, ls = list files etc)

Navigate to the folder with your .cpp files and use g++ to compile your program.

To run your program use ./programname

You will need to install the mac 'developers toolkit' which comes on the DVD with the OS. This gives you g++ and loads of other tools
(most of which I have never used)
Thank you you answered most of my questions :)
Ok, I've got xcode and the GCC compiler because I need compatibility with linux. Can I download the developers toolkit from the App Store instead of the CD, because no CD came with my Mac when I bought it?
Last edited on
Terminal also has vim built-in as a text editor. In case you want to do everything in terminal.

vim my_code.c will create a file (my_code.c) and open it up in an editor.

Failing that, I like to use TextWrangler.
Last edited on
Yeah, Xcode - thats what I meant to say - I think thats enough stuff to get on with.

Xcode might have a programmers editor already in it - can't remember why I used smultron, but I remember smultron worked fine and could be configured to a dark background with coloured syntax highlighting - which is what I like.

If you are a vi/vim person than use that - I prefer a graphical editor.

RE compatibility with linux - all command line stuff will be compatible. If you want to develop graphical apps than you have some considerations to take account of. I think there are a lot of cross platform widget libraries but some may use the aqua stuff and look mac-like when run on a mac and some not. I have used GLUT on mac and the same code compiled on both systems but the compiler options to link in GLUT were different. Running on a mac the app had a mac look.
Yeah I can get it running in xcode now. But text editor and terminal pose a bit of a problem. It's not urgent but I want to work out why I cant get text editor files to compile eventhough I have the gcc compiler installed.

I am typing

gcc -o hello Hello.c

into terminal. and ls gives the following files

Hello.c workspace

I think I needed to download the mac developers tool to get text editor and terminal to work. I tried but I kept getting this error message


ld: symbol dyld_stub_binding_helper not defined (usually in crt1.o/dylib1.o/bundle1.o)
collect2: ld returned 1 exit status

Is it because I need to download mac developers tool kit?
Any ideas it's driving me mad. Cheers
Topic archived. No new replies allowed.