INTRODUCTION TO DATA STRUCTURES RUNNING C++ AT IOWA STATE Gary T. Leavens $Date: 1994/12/28 23:19:47 $ 1. COMPILING, LINKING, AND DEBUGGING There are two flavors of C++ at Iowa State on Computer Science Department machines. The most widely available one is the Free Software Foundation's g++ (actually gcc, version 2.5 as of this writing). This is also found on project Vincent (but you may have to go to some effort to get the same version.) Another is the AT&T C++ version 3.0. (The computer science department has a site license for AT&T's C++ 3.0. Anyone on campus can install this system; there is a fee of $25 per CPU.) If you have a PC, there are many vendors that have C++ environments for you. Ask around to see what other people think of what they have. In Com S 228 we will be using g++. You may write your programs with other systems, but your programs will be expected to work with the g++ compiler on the Com S department HP machines. 2. COMPILING AND LINKING WITH GNU'S G++ 2.1 Using G++ On HP-UX The following gives details about compiling C++ on the Com S department HP-UX machines. The name of the GNU project's C++ compiler is g++. It is used much like the standard C compiler. The standard suffix for C++ code files with this compiler is either .C or .cc; for include files it is .h. The compiler can also be used for linking executables; for example, the command g++ -o test test.o foo.o bar.o links the files test.o, foo.o, and bar.o into a single executable, named test. You can also compile and link in one step; for example g++ -o test test.cc foo.cc bar.cc The g++ debugger is called gdb. There is documentation available in the following file. /usr/local/emacs/info/gdb This can be accessed online through emacs (type C-h i to get into info mode), or using the commands xinfo (on Project Vincent) or info on the Com S department machines. The g++ specific include files are found in the following directory. /usr/local/lib/g++-include The compiled version of the g++ library, libg++.a, is also found in /usr/local/lib. 2.2 Using G++ on Project Vincent Running g++ on Project Vincent is similar to running it on HP-UX. The main difference is that you have to type add gcc before starting work. (You can put this command in your .startup.tty file if you wish.) 3. COMPILING AND LINKING WITH AT&T C++ The AT&T C++ compiler is called CC. See the manual page for details on how to run it. You can also use CC for linking; but the real work of linking (and loading) is done by ld. The standard suffix for C++ code files with this compiler is a capital ``C'' (.C); for include files it is a lower case ``h'' (.h). There is no debugger specifically tailored to C++ for this system. The C++ specific include files are found in the following directory. /usr/local/include/CC Information about the default locations of other stuff you probably don't need to know about is found in the following shell script. /usr/local/bin/CC The standard C++ library is found in /usr/local/lib/libC.a There is also a ``complex numbers library'', which is found in the following file. /usr/local/lib/libcomplex.a You can also use the standard C libraries and other libraries (see below). 4. EDITORS, FORMATTING GNU emacs has macros for editing and formatting C++ code. (If you use vi instead of emacs, try the vi-mode of emacs. You may also want to run the emacs tutorial. Simply start emacs, and read the message it prints.) 5. WHERE TO FIND MORE To find more about C++, read the usenet news group comp.lang.c++. The (answers to the) frequently asked questions from this group are stored in the directory /home/cs228/doc on Com S department machines. $Id: running-c++.txt,v 1.2 1994/12/28 23:19:47 leavens Exp leavens $