JMU JMU - Department of Computer Science
Help Tools
Installing a C++ Development Environment for OS X (Xcode or Xcode/jGrasp)


1 Introduction

There are an enormous number of development environments for C/C++ programmers, some of which are freely available and some of which are commercial products.

This document describes the installation and use of two freely available environments under OS X, one that consists of:

and one that consists of:

jGrasp is less-sophisticated than Xcode but easier to use.

2 Getting Started

The first thing you need to do is register with Apple:

Then you need to download the Xcode installation files:

If you are going to use jGrasp as your integrated development environment (IDE) you need to also download:

3 Installation of Xcode Only

Installation is fairly straightforward:
  1. Install Xcode.

You are now ready to start developing in C/C++ using Xcode as your IDE.

4 Installation of Xcode and jGrasp

Installation is fairly straightforward:
  1. Install Xcode.
  2. Install jGrasp.
  3. Run jGrasp.
  4. Click on Settings, pull down to Compiler Settings, and pull down to Workspace.
  5. Change the language to C++.
  6. Select "c++ (g++) - Mac OS X" or "g++ - generic", click on Use, and click on OK.

You are now ready to start developing in C/C++ and you have two ways to proceed, depending on your personal preferences. You can use jGrasp as your IDE or you can use Xcode as your IDE>

5 Testing the Installation Using jGrasp

To test your installation using jGrasp:
  1. Run jGrasp.
  2. Click on File, pull down to New, and pull down to C++.
  3. Copy and paste the following fragment:
    #include <iostream>
    
    int main(int argc, char **argv)
    {
       std::cout << "Testing 1, 2, 3\n";
       return (0);
    }
    	  
    into the editing window.
  4. Click on File and pull down to Save As and name the file testing.cpp.
  5. Click on Build and pull down to Compile and link.
  6. Click on Build and pull down to Run.

Depending on what else is installed on your computer, this will either cause the message "Testing 1, 2, 3" to be written into the jGrasp Run I/O window or will open a command shell window and execute the program there.

6 Working from within jGrasp

You can compile, link and run applications written in C++ from within jGrasp. However, because of the nature of the C++ development process, it is not as simple as it is with applications written in Java.

The Build menu contains the entries Compile, Compile and Link, Make, and Run (among others). The Compile entry can be used to compile an individual source file. The Compile and Link entry is not very useful because the process of indicating which files should be linked is akward. Hence, it is best to use the Make entry.

The Make entry simply calls the make utility (which must be in your path -- see the discussion in the installation instructions above). The make utility uses a makefile (with a default name of makefile) in the working directory. You can, of course, create/edit this file with jGrasp.

Note that when you run an application from withing jGrasp it assumes that the executable is named a.out.

7 Issues

You should be aware of the following issues:
  1. Many applications (including many development tools) use the space character as a delimiter. This means that, in general, it is a bad idea to use spaces in file names and/or directory names.
  2. See 1.

Copyright 2019