PGPLOT at the ING

Gary F Mitchell
May 1999

This page gives a very basic example of using pgplot

Index

Recipe

Details on linking

The -L flag is followed by a directory name eg /opt/pgplot. The -l flag is followed by the name of a library file - but with the 3 characters "lib" removed from the name of the file. It sounds complex but these options serve to inform the compiler that references to subroutines not in the source code can be resolved by looking at directory /opt/pgplot and search for files libpgplot*. If you or the compiler look at /opt/pgplot you will see
-rw-r--r--   1 root     other      79832 May 14 15:06 /opt/pgplot/libcpgplot.a
-rw-r--r--   1 root     other     776824 May 14 14:58 /opt/pgplot/libpgplot.a
-rwxr-xr-x   1 root     other     503364 May 14 14:58 /opt/pgplot/libpgplot.so
The file libcpgplot.a is for C programs. The file libpgplot.a is an archive of object files. You can examine it's contents using the ar command
gfm@cs1> ar -t /opt/pgplot/libpgplot.a
figdisp_comm.o
gidriv.o
grarea.o
grbpic.o
grchsz.o
...
...
vadriv.o
wddriv.o
x2driv.o
xwdriv.o
The file libpgplot.so is a shared object library. It has the same content as the archive file but in a different form.

When you link the program you either do a static link or a dynamic link.

static link
The compiler collects a copy of the required subroutine from the archive file libpgplot.a and builds it into your application and makes a big image.
dynamic link
The compiler checks that libpgplot.so has what you want and merely annotates the image it is building with an instruction to go get the remaining subroutines from the shared object library at run time.

The option static vs dynamic is controlled by a flag to the compiler such as -Bdynamic or -Bstatic or -dy -dn. The default is to attempt a dynamic link but resort to static if there is no shared obsject library file.

The recommendation of CFG is to accept the system default and have a dynamic link.

Further information

This page is available on-line at http://www.ing.iac.es/~cfg/notes/pub_notes/pgplot/