University of California at Berkeley Department of Electrical Engineering & Computer Sciences Instructional Support Group /share/b/pub/c.help /share/b/pub/cc.help /share/b/pub/c++.help /share/b/pub/g++.help /share/b/pub/gcc.help /share/b/pub/gdb.help /share/b/pub/gcj.help Sep 25 2009 CONTENTS: Overview Compilers and Debuggers on UNIX Systems GNU gcc, gdb, ddd, gcj GNU gcc, gdb: Common Errors GNU gcc, gdb on Solaris X86 GNU gcc, gdb on Solaris SPARC GNU gcc on Windows GNU gcc on Linux GNU 'collector' mips Cross Compiler Chez Scheme C on PCs SUN Forte compilers Overview -------- There are a variety of C and C++ compilers on the EECS Instructional UNIX, PC and Macintosh systems. Each version of UNIX has its own ANSI C compiler and libraries, typically located in /usr/bin and /usr/lib. Please read /share/b/pub/software.help for information about setting UNIX search paths for programs and man pages. The GNU products (gcc, gdb) are installed in /usr/sww/bin and can be investigated using the command "/usr/sww/bin/info". On systems where GNU tools are not the default (Solaris), the programs are prepended with the letter 'g'. Onsystems where GNU tools are the default (Linux, MacOSX), the 'g' is omitted. So "gcp" on a Solaris system is equivalent to "cp" on a Linux system. 'gcc' and 'gdb' are exceptions. The SUN compilers are installed on Solaris SPARC and X86 systems in the /usr/sww/opt/SUNWspro directory. It includes C, C++ and Fortran. Don't use /usr/ucb/cc. It typically gies the error "language optional software package not installed". Microsoft Visual Studio compilers are available on Windows workstations and servers. Please see /share/b/pub/microsoft.help. Apple XCode is on some MacoSX systems. Please see /share/b/pub/mac.help. PalmOS software tools are available; see "PalmOS" under http://inst.eecs.berkeley.edu/software. Debuggers on Different UNIX Systems ----------------------------------- This is a quick-reference list of which debugging tools are available on which Instructional UNIX platforms. Debuggers supported under Solaris X86: adb - general-purpose ("absolute") debugger ddd - the data display debugger (with X interface) gdb - The GNU Debugger gjdb - a locally-developed Java debugger, for CS61b jdb - Java debugger Debuggers supported under Solaris SPARC (quasar.cs, pulsar.cs): gdb - in /usr/sww/bin/gdb (32-bit code only) * ddd - the data display debugger dbx - in /usr/sww/opt/SUNWspro/bin/dbx (32/64-bit code) adb - in /bin/adb (32/64-bit code) See "GNU gcc, gdb on Solaris SPARC" below for details. * The GNU Debugger is currently not working properly under the solaris sparc systems. GNU gcc, gdb, ddd, gcj ---------------------- "gcc" and "gdb" are accessed from /usr/sww/bin on the Instructional UNIX systems in Soda and Cory Halls. "gcj" (compiles Java source code or byte code to native binary code) is available on our Linux systems in /usr/bin/gcj. For the current names, locations and operating systems of our systems, please see http://inst.eecs.berkeley.edu/~inst/iesglabs.html. gdb can work with Fortran and C code, with the commands set lang fortran set lang c (Pascal code is not suported, as ther is no command "set lang pascal".) Note that more than one version is typically available. The command "gcc -v" will display the current default version. You can invoke gcc with the "-V" option to get a specific version, such as: % gcc -V2.7.2.3 -o foo foo.c Or, set your path to point into /usr/sww/lang to find the compiler you want, e.g., torus% ls /usr/sww/lang java jdk-1.1.8 jdk-1.3.1_02 jdk-1.4.1_02 java1 jdk-1.2.2 jdk-1.3.1_07 mips java2 jdk-1.2.2_14 jdk-1.4.1_01 torus% set path = ( /usr/sww/lang/mips/bin $path ) torus% rehash torus% gcc -v Reading specs from /usr/sww/lang/mips/lib/gcc-lib/mips-dec-ultrix4.3/2.95.2/specs gcc version 2.95.2 19991024 (release) Be careful to update your Makefile(s) when you make such changes. "gcc" and "gdb" are also installed for Solaris systems in /usr/sww/bin. The command "/usr/sww/bin/info" gives details. The file servers for /usr/sww are different computers in Soda and Cory Halls, so the versions of gcc installed in /usr/sww/bin may differ on computers in each building. "ddd" is a debugger with a graphical front end. GNU gcc, gdb: Common Errors --------------------------- TEMPLATES: Older versions of g++ and STL generate error messages about ambiguous template instantiations if the classes are not defined in a specific order. That is, this works: #include #include But this fails: #include #include This problem is solved with g++ 2.7.2.3 and the Moscow/SGI port of STL (available from http://www.ipmce.su/~fbp/stl/). Similarly, you may find that older C++ code does not include explicit template instantiation statements; you might want to include more of these if you find that the compiler chokes on your templated code. If you get an error message such as fatal: libstdc++.so.5: open failed: No such file or directory it is probably because the compiler does not know where the libraries are. You can solve that by giving the options command-line options -L/usr/sww/lib -R/usr/sww/lib The -R option specifies Runtime linking behavior. The -L specifies compile time linking behavior. GNU gcc, gdb on Solaris X86 --------------------------- gcc, g++ and gdb are installed in the /usr/sww/bin directory. The current version of gcc and g++ is version 3.2.1 (Feb 2003) The current version of Solaris is 2.8. (Feb 2003) Shared libraries: The current version of gcc on Solaris X86 now automatically passes the appropriate -R value (library path) to ld. For older versions, if your compiled g++ program generates an error such as fatal: libstdc++.so.2.8.1.1: open failed: No such file or directory you should include " -R/usr/sww/pkg/gcc-2.8.1/lib " in your g++ command line or add /usr/sww/pkg/gcc-2.8.1/lib to your LD_LIBRARY_PATH environment variable. This is only a problem for the older version(s) of g++, such as v 2.8.1.1, that are no longer the default version. The default location of shared library finds a newer version of the library, so you must explicitly list the location of the older library. (Nov 2000) Debugger: Use the -gstabs+ command line option to include debugging symbols. This uses the Solaris DWARF data format, which is compatible with the GNU 'gdb' debugger. Manuals: more /usr/sww/pkg/gcc/info/gcc.info setenv MANPATH ${MANPATH}:/usr/sww/pkg/gcc/man man gcc Native Sun compilers and "make" are in /usr/ccs/bin; however, the SunPro C compiler is not currently licensed for use on the Instructional machines (Jul 1999). GNU gcc, gdb on Solaris SPARC ----------------------------- gcc, g++ and gdb are installed in the /usr/sww/bin directory. The current version of gcc and g++ is version 3.2.1 (Feb 2003) The current version of Solaris is 2.8. (Feb 2003) Shared libraries: The current version of gcc on Solaris SPARC does NOT automatically pass the appropriate -R value (library path) to ld. This is different than the behavior on our Solaris X86 systems, because SPARC systems can use either 32-bit or 64-bit libraries, and the user must specify which one. For 32-bit libraries, include " -R/usr/sww/lib" in your g++ command line or add /usr/sww/lib to the LD_LIBRARY_PATH environment variable. For 64-bit libraries, include " -R/usr/sww/lib/64" in your g++ command line or add /usr/sww/lib/64 to the LD_LIBRARY_PATH environment variable. Debugger: The 64-bit 'gdb' is broken (March 2002), which means it can't be used on the Solaris SPARC systems. 64-bit code can be debugged using: /usr/sww/opt/SUNWspro/bin/dbx (64-bit debugger) /bin/adb (Solaris native 32-bit and 64-bit debugger) The 32-bit 'gdb' works on the Solaris X86 systems (po, torus, rhombus, pentagon, PCs in 277 Soda), as does 'adb'. GNU gcc on Windows ------------------ GNU gcc is not currently installed (Jul 1999) on Instructional Microsoft Windows workstations. If you are interested, browse the website at http://cygwin.com/ and decide whether the environment will meet your needs; if you think that it will, contact us for help (e-mail inst@eecs.berkeley.edu). GNU tools on Linux ------------------ On Linux systems where GNU tools are the default, most GNU tools don't start with a 'g'. For example, "gcp" on a Solaris system is just "cp" on a Linux system. 'gcc' and 'gdb' are exceptions. GNU 'collector' -------------- From brg@cory.EECS.Berkeley.EDU Fri May 7 10:32:32 1999 Subject: Re: g++ collector > Where is the g++ collector (i.e. collect2)? > I can't find collect2 anywhere on the instructional systems. It depends on the architecture (target platform) and the compiler you're using. collect2 is not always used, especially if the GNU linker can be built for the target platform; when it is, it's invariably installed inside the gcc-lib tree. Which compiler are you using? I note that you sent mail from parker, which is an HP; on that machine, there are three versions of g++ installed, each with its own collector (a "thin" interface to the HP linker, /usr/bin/ld.) /share/d/hppa1.1-hp-hpux10.20/bin/g++ (same as /usr/local/bin/g++, GCC 2.7.2.3, the most ancient compiler) uses: /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.7.2.3/ld /usr/sww/bin/g++ (GCC 2.8.1) uses: /usr/sww/pkg/gcc-2.8.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.8.1/ld You can find the collector or linker using this simple heuristic: % set libgcc = `gcc --print-libgcc-file-name` ^^^-- where "gcc" is the compiler you're using % cd `dirname $libgcc` % ls -l `pwd`/collect2 `pwd`/ld mips Cross Compiler ------------------- (Jul 1999) A MIPS cross compiler for the Instructional Solaris x86 workstations is available under the directory /usr/sww/lang/mips/bin. (Jan 2000) A MIPS cross compiler for the Instructional Solaris SPARC server is available under the directory /share/instsww/lang/mips/bin. To use these tools, add the directories to your path: % set path = ( /share/instsww/lang/mips/bin /usr/sww/lang/mips/bin $path ) % rehash You can add the above "set path" command to the end of your ~/.cshrc to make it a permanent setting for future logins. Available on Solaris x86: (Jul 1999) - gcc version 2.95 19990718 (prerelease) - GNU binutils version 2.9.5.0.3 Available on Solaris SPARC: (Jan 2000) - gcc version 2.95.2 19991024 (release) - GNU binutils version 2.9.1.0.25 The gcc MIPS cross-compiler is an option for compiling binary or assembly code for the DEC MIPS architecture. The DEC MIPS architecture was used on the older DEC workstations running DEC's ULTRIX operating system. (These are not the same as the new DEC Alpha systems, which run DEC UNIX, aka "OSF1". Type the "uname" command on your computer to see which type of computer you are using.) You can use this program to compile code for Volga, the Instructional MIPS server. To compile a program named "mycode.c", you can type: % mips-dec-ultrix4.3-gcc -o mycode mycode.c To generate assembly code, use the "-S" option, for example: % mips-dec-ultrix4.3-gcc -S mycode.c The following MIPS cross tools of interest are installed: mips-dec-ultrix4.3-addr2line, looks up lines in source code given addresses in binary code mips-dec-ultrix4.3-ar, creates object file archives (.a files) mips-dec-ultrix4.3-as, GNU assembler for MIPS assembly language mips-dec-ultrix4.3-g++, also called mips-dec-ultrix4.3-c++, GNU C++ compiler mips-dec-ultrix4.3-c++filt, C++ name de-mangler; run it like this: nm c++objectfile.o | c++filt to see the real method names mips-dec-ultrix4.3-gasp, GNU Assembler macro preprocessor mips-dec-ultrix4.3-gcc, GNU C compiler mips-dec-ultrix4.3-gcj, front end to GNU Java compiler (NOT installed) mips-dec-ultrix4.3-ld, GNU linker for MIPS ECOFF binary files mips-dec-ultrix4.3-nm, provides symbol table listings of ECOFF binaries mips-dec-ultrix4.3-objcopy, translates, adjusts, and extracts sections from MIPS ECOFF binary files mips-dec-ultrix4.3-objdump, advanced GNU disassembler/ECOFF binary file lister mips-dec-ultrix4.3-protoize, inserts prototypes into C/C++ code mips-dec-ultrix4.3-ranlib, generate indices for quick random access to archive (.a) files mips-dec-ultrix4.3-readelf, ELF-specific binary file lister mips-dec-ultrix4.3-size, lists section sizes and total in-core size of a binary file mips-dec-ultrix4.3-strings, lists printable ASCII strings from files mips-dec-ultrix4.3-strip, removes debugging/symbol table info from files mips-dec-ultrix4.3-unprotoize, removes prototypes from C/C++ code Note that configuring programs that use GNU autoconf to use the cross compiler can be tricky; sometimes you can get better results by configuring the program on volga to use the native compiler and then editing the Makefiles, etc., by hand to reference mips-dec-ultrix4.3-gcc instead of gcc. (Jul 1999) Note: The C++ cross-compiler, while available, is not currently supported because the C++ standard library is not available for the DEC ULTRIX platform. (Sep 1999) Chez Scheme ----------- Codecenter (Saber C) from Centerline, Inc., Cambridge MA, was used in some CS classes in the early 1990's but is no longer supported on the EECS Instructional computers. C on PCs -------- These compilers are available: GNU gcc in 330 Soda: (see above, "GNU gcc on NT") Microsoft Visual C++ in 199 Cory, 330 and 349 Soda Please contact "inst@eecs.berkeley.edu" if you would like to use one of these for work related to an EECS class. SUN Forte compilers ------------------- The SUN compilers, formerly called "Forte" are installed on on all Solaris SPARC and X86 systems in EECS, in the /usr/sww/opt/SUNWspro directory. It includes C, C++ and Fortran. For more information about usage and licensing for SUN Forte, lease see /share/b/pub/forte.help. EECS Instructional Support 378/384/386 Cory, 333 Soda inst@eecs.berkeley.edu