Department of Mathematics - University of Utah

HomeComputingCourse SchedulesCSMECurrent PositionsFAQ (Computing)FormsGraduateHigh SchoolLecture VideosMailbox AccessMath BiologyMath EducationNewsletterPeopleResearchRTG GrantsSeminars

Using the NAG C libraries at the University of Utah Mathematics Department

Last update: Sat Nov 17 16:23:13 2001

Comments, and reports of errata or bugs, are welcome via e-mail to the author, Nelson H. F. Beebe <beebe@math.utah.edu>. In your report, please supply the full document URL, and the title and Last update time stamp recorded near the top of the document.

In the Mark 18 release of the NAG C libraries, there are regrettable inconsistencies in internal #include statements which, on most machines, make it necessary to supply the compiler with two different locations of header files. On all local systems and compilers, these take the form -I/usr/local/include and -I/usr/local/include/Nag.

On each architecture, the second of these directories is a symbolic link to the appropriate directory in the installation tree, /usr/local/sys/nag/nag5, thereby masking the system-dependent directory name with a uniform name.

Similarly, the NAG C library is always available as files /usr/local/lib/libnagc.{a,so,sl}; these are symbolic links into the NAG installation tree. This makes it possible to refer uniformly to the library with compiler switches -L/usr/local/lib -lnagc.

On some architectures, there may be additional versions of the NAG libraries that have been compiled for specific CPU architectures or memory models, and depending on your processor, they may offer higher performance. Of necessity, the default installations include only the libraries that match the least-common denominator of architectures and memory models. If this applies to you, then you need to read the NAG installation notes; look for the topics beginning C Header Files for Marks 15 to 18 and NAG C Library in that long list.

The little test program, cnagtest.c, used below is available for your inspection. Each system section below contains a pointer to a large collection of more than 300 NAG-supplied sample files.

Some C and C++ compilers automatically search the /usr/local/include directory for header files, and the /usr/local/lib directory for load libraries, and thus do not require additional -Idir and -Ldir switches. The examples below show the minimal command line required in each case.


Compaq/DEC Alpha OSF/1 4.0 (also known as Tru64)

c89 -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
cc  -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
CC  -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
cxx -x cxx -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
g++ -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
gcc -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
lcc -Ualpha -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm

The reason for the -Ualpha switch for lcc is that the compiler otherwise defines that name as an architecture flag, and that then incorrectly redefines a variable in the header file <Nag/nag_types.h>.

Further examples are available.


HP HP-UX 10.01

gcc -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
c89 -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -L/usr/local/lib -lnagc -lm
g++ -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -L/usr/local/lib -lnagc -lm
CC -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -L/usr/local/lib -lnagc -lm

Further examples are available.


Intel GNU/Linux

g++ -o cnagtest cnagtest.c -lnagc -lm
gcc -o cnagtest cnagtest.c -lnagc -lm
lcc -I/usr/local/include -o cnagtest cnagtest.c -lnagc -lm
pgcc -o cnagtest cnagtest.c -lnagc -lm
pgCC -o cnagtest cnagtest.c -lnagc -lm

Further examples are available.


SGI IRIX 5.3

cc -I/usr/local/include  -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
CC -I/usr/local/include  -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
g++ -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
gcc -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
lcc -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm

Further examples are available.


SGI IRIX 6.5

c89 -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
cc -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
CC -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
g++ -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm
gcc -I/usr/local/include -I/usr/local/include/Nag \
    -o cnagtest cnagtest.c -lnagc -lm

lcc does not work with the NAG library: it produces -o32 memory-model object files, and there are none in the NAG C libraries.

Further examples are available.


Sun Solaris 2.x

c89 -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm
CC  -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm
cc  -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm
g++ -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm
gcc -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm
lcc -I/usr/local/include \
    -o cnagtest cnagtest.c -lnagc -lm

Further examples are available.


Dept Info Outreach College of Science Newsletter

Department of Mathematics
University of Utah
155 South 1400 East, JWB 233
Salt Lake City, Utah 84112-0090
Tel: 801 581 6851, Fax: 801 581 4148
Webmaster


Entire Web                     Only http://www.math.utah.edu/