Computer Science Canada

Editing/compiling on a Mac

Author:  slAag [ Mon Oct 29, 2007 3:23 pm ]
Post subject:  Editing/compiling on a Mac

Does anyone know what I should use and how I should compile on a Mac? Everything I've seen so far is for windows. Try and keep the downloads small too, cause im on dial-up...

Author:  rdrake [ Mon Oct 29, 2007 3:38 pm ]
Post subject:  RE:Editing/compiling on a Mac

I thought Xcode supported C++, and that g++ was installed by default? It should be on your install disc. You can use any old editor for writing code if you wish, and something like the following to compile:

code:
g++ <file>.cpp -o <file>

Author:  slAag [ Mon Oct 29, 2007 3:50 pm ]
Post subject:  Re: Editing/compiling on a Mac

Could you explain a little better? Im not really familiar with this stuff yet, but i did find a file called "Xcode Tools". Am i on the right track with that?

Author:  Clayton [ Mon Oct 29, 2007 3:57 pm ]
Post subject:  RE:Editing/compiling on a Mac

Sounds right. And the above line that rdrake put in code tags is what you type in the terminal to compile your code, replacing <file> with the actual filename of course.

Author:  slAag [ Mon Oct 29, 2007 4:15 pm ]
Post subject:  Re: Editing/compiling on a Mac

Well, ill go mess around with it for a bit then and try to figure out what im doing.

Author:  slAag [ Mon Oct 29, 2007 5:39 pm ]
Post subject:  Re: Editing/compiling on a Mac

Well, the Xcode editor wont let me compile the file for some reason. Could you tell me how to get into the command line?

Author:  Tony [ Mon Oct 29, 2007 6:04 pm ]
Post subject:  RE:Editing/compiling on a Mac

Xcode does indeed come with the GCC suite, so g++ should be on your system. Though an enterprise level IDE such as Xcode is not needed (and indeed could be a bit overwhelming) for a beginner.

Your terminal is located in.. well: Appications -> Utilities -> Terminal

I would strongly encourage to keep it in your dock though.

Author:  slAag [ Mon Oct 29, 2007 6:57 pm ]
Post subject:  Re: Editing/compiling on a Mac

Thanks, I keep everything in my dock Smile Yeah, Xcode is a little overwhelming, but i think ive got the gist of it.

Author:  slAag [ Mon Oct 29, 2007 7:21 pm ]
Post subject:  Re: Editing/compiling on a Mac

K, i have it mostly figured now, and its working. Thanks for all your help guys.

Author:  wtd [ Tue Oct 30, 2007 12:13 am ]
Post subject:  RE:Editing/compiling on a Mac

Oh, and makefiles are your friend!

Author:  slAag [ Tue Oct 30, 2007 3:06 pm ]
Post subject:  Re: Editing/compiling on a Mac

makefiles?

Author:  wtd [ Tue Oct 30, 2007 3:27 pm ]
Post subject:  RE:Editing/compiling on a Mac

http://en.wikipedia.org/wiki/Makefile

Author:  slAag [ Tue Oct 30, 2007 3:45 pm ]
Post subject:  Re: Editing/compiling on a Mac

Is there a way to clean up the output screen a bit? When i run the "hello world!" program, i get this in the output window.

Last login: Tue Oct 30 16:28:24 on ttyp2
/Users/<user>/Desktop/C++/helloworld; exit
Welcome to Darwin!
[<name of computer>:~] <user>% /Users/<user>/Desktop/C++/helloworld; exit
Hello world!logout
[Process completed]

Author:  Tony [ Tue Oct 30, 2007 4:03 pm ]
Post subject:  RE:Editing/compiling on a Mac

There is nothing extra in that output, everything appears as expected. Though if you don't call the exit (why are you doing that?), you don't have to see the welcome/exit statements more than once.

Author:  slAag [ Tue Oct 30, 2007 4:18 pm ]
Post subject:  Re: Editing/compiling on a Mac

I dont think i did anything extra... But i only started C++ yesterday, so i wouldnt be surprised if i did.


: