Apple XCode for C and C++If you want to learn to program on a Mac, XCode is the way to go. This tutorial will get you set up to do C or C++ development with XCode, but you can also use XCode for iPhone and iOS development.Installing XCode will give you access to a powerful IDE as well as command line tools like gcc and g++ in addition to a graphical IDE. (You need to install XCode even to get g++ and gcc.) XCode comes by default with your system, but is not installed--it's on the system disk, or you can download the latest version from the Apple website. Downloading Apple XCode
Using Apple XCodeOnce you've downloaded XCode, you can install it from the disk image. Then you can run XCode from Developer|Applications|XCode. XCode has lots of documentation and can walk you through setting up a project.The very simplest thing to do is to create a new project from "File|New Project...". First choose "Application" and then "Command Line Tool". This will give you a basic command line program that you can use when you're learning to program. Before you leave that screen, make sure to change the "Type" of the project to "C++ stdc++" if you are using C++ instead of C. Go through the rest of the prompts and create your new project. Now you have a small project set up that has a main.cpp file. You can edit main.cpp, but by default it will include a small sample "hello world" program. Let's go ahead and run that sample program--select "Build and Run" button from on the toolbar. This will compile your program, but I find that it won't actually run it. To do that, you need to double-click the executable file. By default, you should see that the executable file is in the top window, along with main.cpp and a file ending with .1 (a file that's there for creating a man page). When you first start out, the executable will be colored red, but once you build, it will look normal. Go ahead and double-click it and you can see your program execute. Continue to Intro to C++ (or Intro to C). |