<<

How to compile C++ programs

Apple provides an Integrated Development Environment (IDE) called . XCode comes on your OS 10.5 distribution disk called “Developers Tools”, and it is also available free for you to download : http://developer.apple.com/technology/xcode.html

You will have to get a free Apple Developer Connection membership in order to download XCode. Only the most recent version of XCode will compile C++ programs. This means you must have OS 10.5 installed on your Macintosh, together with XCode 3.1.2. If you have an older Macintosh, one that is not able to run OS 10.5, you will have to use the in the lab here at Foothill to do your homework.

1. Install XCode 3.1.2 from the URL above. 2. After installation, locate and run the XCode application

3. From XCode’ menu, choose “New Project...” 4. On this dialog box, scroll down until you see “Carbon C++ Application” and choose it. Name your new project “Lab1” and choose where on your hard disk to store it. 5. When the new project dialog box is finished, you will see a project on the left side of the window and a folder called “Sources” below it. Click on the triangle next to “Sources’ to open that folder and double click the file “Main.cp” to open it in the editor portion of that window. The editor is the lower right frame of the window. 6. Delete the contents of the editor frame and replace it with the program you would like to write. Choose File‐Save. 7. Pull down the FIle menu and choose Run. Pull down the Run menu and choose Console so that you can see the output of your program. 8. If you like your output, select it from the console window and choose Edit – Copy to put your output on the console. Place your cursor into the bottom of your in the Editor frame and choose Edit‐Paste. Place comment markers around your output so that this source code file will continue to compile and run. Choose File‐Save again. 9. the file (probably called “main.cp”) on your hard disk and submit it through etudes.