Auburn University http://www.eng.auburn.edu/~xqin COMP 2710 Software Construction xCode Development Environment for C++ Programming in Mac OS Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin xqin@auburn.edu This is an all-in-one version, which include: Lec01b1-Write your first c++ program.ppt Lec01b2-Using the Eclips IDE Note that a warming-up exercise is in a separate file: Lec01b2- Warming-up Exercises.ppt (this one is NOT covered in the lecture) To be continued on page 10.
xCode in Mac OS C or C++ development with XCode XCode for iPhone and iOS Reference: http://www.cprogramming.com/xcode.html
xCode Offers A powerful IDE Command line tools: g++ and gcc 1-3 3
What is xCode? Provide a GUI editor (like Visual Studio) Provide an interface that includes a project into which program files are loaded (like Eclips and jGrasp) Allow you to compile a program and displays any error messages generated Allow you to run a program and provide an output window with results You can either download the full XCode environment including documentation (2.3GB) or download a stripped-down version that that is about 750MB. If you want to download the smaller version of XCode that doesn't include documentation, click on "Developer Downloads". (Much of the documentation will not be relevant to you when you are just starting to learn C++, and the Apple website itself already makes extensive documentation available.) Click on "Developer Tools" under the "Downloads" sidebar Search for the latest version of XCode (you want something like that looks like "XCode X.Y.Z Developer Tools", for example "XCode 3.2.2 Developer Tools") 1-4 4
Downloading xCode Register as an Apple developer http://developer.apple.com/programs/register/ It is free Download at Mac Dev Center: http://developer.apple.com/devcenter/mac/login.action Full version (2.3GB) or stripped-down (750MB) You can either download the full XCode environment including documentation (2.3GB) or download a stripped-down version that that is about 750MB. If you want to download the smaller version of XCode that doesn't include documentation, click on "Developer Downloads". (Much of the documentation will not be relevant to you when you are just starting to learn C++, and the Apple website itself already makes extensive documentation available.) Click on "Developer Tools" under the "Downloads" sidebar Search for the latest version of XCode (you want something like that looks like "XCode X.Y.Z Developer Tools", for example "XCode 3.2.2 Developer Tools") 1-5 5
Downloading xCode http://developer.apple.com/technology/xcode.html Reference: http://www.macworld.com/article/1046286/installxcode.html Double click the Disk Image of xCode 1-6 6
Installing xCode: Follow the usual Apple installer routine Reference: http://www.macworld.com/article/1046286/installxcode.html Double click the Disk Image of xCode Follow the usual Apple installer routine When the process is done, you’ll have a brand-new set of Developer Tools, installed and ready for your use. 1-7 7
Installing xCode from Terminal Reference: http://www.mactricksandtips.com/2010/02/installing-xcode.html 1-8 8
Inside the Terminal window Type: (do not type $) $xcode-select --install 1-9 9
Install the command line tools 1-10 10
How to install the g++ compiler in Mac OS? It comes with the Apple's XCode tools You can either download the full XCode environment including documentation (2.3GB) or download a stripped-down version that that is about 750MB. If you want to download the smaller version of XCode that doesn't include documentation, click on "Developer Downloads". (Much of the documentation will not be relevant to you when you are just starting to learn C++, and the Apple website itself already makes extensive documentation available.) Click on "Developer Tools" under the "Downloads" sidebar Search for the latest version of XCode (you want something like that looks like "XCode X.Y.Z Developer Tools", for example "XCode 3.2.2 Developer Tools") 1-11 11
Type in the Terminal window: (do not type $) Have you installed g++? Type in the Terminal window: (do not type $) $g++ --version 1-12 12
How to create a c++ project in xCode? Open xCode, then: “Tools -> C++ Tool” Reference: https://www.cs.drexel.edu/~mcs171/Wi07/extras/xCode_Instructions/index.html Reference: https://www.cs.drexel.edu/~mcs171/Wi07/extras/xCode_Instructions/index.html 1-13 13
Name and Path of the Project 1-14 14
What items are in myProject? In the "myProject" window, you will see that a program named "main.cpp" has been created and installed in the project by default. (Sometimes these wizards are a little too helpful, if you know what I mean.) This program almost certainly does not do what you want it to do, but it is a fully-functioning C++ program. This means you can compile and run it right now. Go ahead, if you must. We'll wait for you to get it out of your system. 1-15 15
You may change the name of the source code file select File->Save As... In the "myProject" window, you will see that a program named "main.cpp" has been created and installed in the project by default. (Sometimes these wizards are a little too helpful, if you know what I mean.) This program almost certainly does not do what you want it to do, but it is a fully-functioning C++ program. This means you can compile and run it right now. Go ahead, if you must. We'll wait for you to get it out of your system. 1-16 16
Modify your source code file 1-17 17
Compile and run your program 1-18 18
Watch this YouTube Video for more information on xCode https://www.youtube.com/watch?v=FzuDUnoNQo0 Length 8:24 1-19 19