Getting Started with C/C++ on the UM Research
C/C++ is available on willow for the
instructional and research use of the students, faculty, and
staff of the University of Mississippi.
What is willow's IP address?
Do I use telnet/FTP, or secure shell/SFTP, to connect to willow and tranfer files from willow?
Telnet and FTP have been disabled on willow for security purposes, so your only choice is secure shell/SFTP. See more information on secure shell.
How can I apply for an
individual account, or a set of class accounts, on
Follow the instructions under Non-Research Account
Categories on the
MCSR Accounts page.
compilers are installed on willow?
C Compiler and the SUN STUDIO 8 C/C++ Compilers.
What environment variable
settings are necessary for me to compile C/C++ programs
Your PATH environment variable should simply contain
/usr/local/bin, since this is where the compiler
exectuables are located on willow. Also, the LD_LIBRARY_PATH should
include the path /usr/local/lib.Otherwise, the executable created by
the compiler will cause an error due to the library link problem.
What suffixes should I give to my C
and C++ source files, to ensure proper processing?
.cpp, .cc, or .C
for C++ programs that are to be preprocessed, compiled
.c, for C
programs that are to be processed, compiled, and
.h for preprocessor (header) files; not
usually named on command line.
How can I compile and
link a C program on willow with the gcc compiler?
gcc file1.c file2.c ...
How can I compile and
link a C++ source program on willow with the gcc compiler?
g++ file1.cpp file2.cpp ...
How can I tell the compiler where to
find an included preprocessor (.h) file that is not in
the current compilation directory or in any of the
default system include directories?
Which says to look in the directory named directory. For
example, if you want to compile program bball.cpp which
has a directive including preprocessor file bball.h as
follows: #include "bball.h"
the compiler will find it if you specify:
g++ ball.cpp -I/tmp
How can I compile one
or more C++ source files into object files, without yet
linking them into an executable program?
By using the -c option, which supresses the linking phase
of compilation, as follows:
g++ -c file1.cpp
which will create one object (.o)
file for each source file compiled, but will not create
an a.out file.
How can I ensure that
the compiler can find/link a C/C++ library module that my
Which says to use the library named library when linking.
The linker searches a standard list of directories for
the library, which is actually a file named
`liblibrary.a'. The linker then uses this file as if
it had been specified precisely by name.
The directories searched include several standard system
directories plus any that you specify with `-L'.
Normally the files found this way are library
files-archive files whose members are object files. The
linker handles an archive file by scanning through it for
members which define symbols that have so far been
referenced but not defined. However, if the linker finds
an ordinary object file rather than a library, the object
file is linked in the usual fashion. The only difference
between using an `-l' option and specifying a file name
is that `-l' surrounds library with `lib' and `.a' and
searches several directories.
Example: If you have compiled a function playGame() into
an object file, and archived that object file as a member
in an archive library file called libroundball.a, which
is in directory /tmp, and you want to compile a program
in file bball.cpp which makes a call to playGame(), you
would compile/link as follows:
g++ myfile.cpp -L/tmp
which tells the compiler to look in
directory /tmp for a library called libroundball.a to
find any otherwise undefined symbols--namely, playGame()
How can I create a C/C++
library module in an archive directory, so that it may be
called (and found) by other programs on willow?
By using the Unix archive command ar.
Example: The following example will compile a reusable
function playGame() into an object file, then add that
object file as a member of a new library archive called
g++ -c playGame.cpp
/usr/ccs/bin/ar -rc libroundball.a playGame.o
for more information, see
How can I tell the compiler
what to name the executable program--other than a.out?
With the -o option, like this:
g++ -o myfile.exe myfile.cpp
which will will put your executable program in myfile.exe
When I try to compile/link
my C++ program, why do I get this error message:
Undefined symbol...ld: fatal: Symbol referencing
errors. No output written to a.out.
Your program is probably calling a function, the
object code for which cannot be found by the loader.
If you are trying to call a function defined in another,
separately compiled program, make sure that you have
included that programs object file (.o file) in the
If you are trying to call a function defined in static
library, make sure you specify on the command line the
name of the library (-llibrary) and it's location in the
file system (-Ldirectory).
(See the q/a above on library
When I try to execute my
a.out program, why do I get error message:
a.out: not found.
You can fix this by either prepending the command with ./, as in:
Or by adding the current directory to your PATH
See also: Path
running shell scripts, and managing