Next: , Previous: The Plotter Class, Up: C++ Programming


9.3.2 C++ compiling and linking

The source code for a graphics application written in C++, if it is to use libplotter, must contain the line

     #include <plotter.h>

The header file plotter.h is distributed with libplotter, and should have been installed on your system where your C++ compiler will find it. It declares the Plotter class and its derived classes, and also contains some miscellaneous definitions. It includes the header files <iostream.h> and <stdio.h>, so you do not need to include them separately.

To link your application with libplotter, you would use the appropriate ‘-l’ option(s) on the command line when compiling it. You would use

     -lplotter -lXaw -lXmu -lXt -lXext -lX11 -lpng -lz -lm

or, in recent releases of the X Window System,

     -lplotter -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lpng -lz -lm

These linking options assume that your version of libplotter has been compiled with PNG support; if not, you would omit the ‘-lpng -lz’ options.

As an alternative to the preceding, you may need to use ‘-lplotter -lXm -lXt -lXext -lX11 -lpng -lz -lm’, ‘-lplotter -lXm -lXt -lXext -lX11 -lpng -lz -lm -lc -lgen’, or ‘-lplotter -lXm -lXt -lXext -lX11 -lpng -lz -lm -lc -lPW’, on systems that provide Motif widgets instead of Athena widgets. In recent releases of the X Window System, you would insert ‘-lSM -lICE’. Recent releases of Motif require ‘-lXp’ and possibly ‘-lXpm’ as well.)

On some platforms, the directories in which libplotter or the other libraries are stored must be specified on the command line. For example, the options ‘-lXaw -lXmu -lXt -lSM -lICE -lXext -lX11’, which specify X Window System libraries, may need to be preceded by an option like ‘-L/usr/X11/lib’.

On most systems libplotter is installed as a shared library. This means that the linking with your application will take place at run time rather than compile time. The environment variable LD_LIBRARY_PATH lists the directories which will be searched for shared libraries at run time. For your application to be executable, this environment variable should include the directory in which libplotter is stored.