Installing a C++ Development Environment for UNIX/Linux (GNU CC, 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 one freely available
environment that consists of:
- GNU Compiler Collection
- jGrasp
running under UNIX/Linux.
2 Getting Started
The GNU Compiler Collection is installed on most UNIX/Linux systems. So,
you probably only need to download the installation file for jGrasp:
3 Installation
Installation is fairly straightforward:
- Install jGrasp.
- Run jGRASP.
- Click on Settings, pull down to
Compiler Settings, and pull down to
Workspace.
- Change the language to C++.
- Select "g++ - generic", click on
Use, and click on
OK.
4 Testing the Installation Using jGRASP
To test your installation using jGRASP:
- Run jGRASP.
- Click on File, pull down to
New, and pull down to
C++.
- 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.
- Click on File and pull down to
Save As and name the file
testing.cpp
.
- Click on Build and pull down to
Compile and link.
- 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.
5 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.exe
.
6 Working from the Command Shell
Once you have a terminal window running, you can use the
text editor of your choice (e.g.,
VIM
to create files,
the
G++ compiler to compile and link,
and the
GNU make utility to manage projects.
7 Issues
You should be aware of the following issues:
- 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.
- See 1.