next up previous 204
Next: References
Up: EMS Error Message Service
Previous: C Language Interface


Compiling and Linking with the Error Message Service

There are three Fortran include files available for use with the Error Message Service: SAE_PAR, EMS_PAR and EMS_ERR (see Appendix [*] for details of the symbolic constants which they define). The Starlink convention is that the name in upper case with no path or extension is specified when including these files within Fortran code, e.g.:
*  Global Constants:
      INCLUDE 'SAE_PAR'
      INCLUDE 'EMS_PAR'

Assuming that the software has been installed in the standard way and /star/bin has been added to the environment variable PATH, soft links with these upper-case names pointing to the required Fortran include files are set up in the user's working directory by the commands:

% star_dev
% ems_dev

Equivalent header files are installed in -I/star/include for use in C code which is calling EMS - they are named sae_par.h, ems_par.h and ems_err.h. In addition, ems.h contains the function prototypes for each of the C functions. The syntax

#include "sae_par.h"
#include "ems.h"
should be used within the C code, and the compiler option -I/star/include used.

The Error Message Service is included automatically when programs are linked using the ADAM application linking commands, alink etc.

To link a non-ADAM Fortran program with the the Error Message Service, the command line would be:

% f77 program.o -L/star/lib `ems_link` -o program.out
On platforms with shareable libraries, -L/star/lib might be replaced by -L/star/share.

If it is necessary to link explicitly with the ADAM version of EMS and any libraries which it uses (e.g. to produce a shareable library), the script ems_link_adam is available in /star/bin. The link command might be:

% ld -shared -o libmypkg.so.1.0 -L/star/share -lmypkg `ems_link_adam`
(In fact, ems_link and ems_link_adam are now functionally identical.)

The command to compile and link a C program might be:

% cc -o program -I/star/include -L/star/lib program.c `ems_link`

Note that the command used to invoke the C compiler varies from one UNIX implementation to another (indeed, there may be more than one C compiler available on the same machine) - you should therefore check this with your Site Manager before proceeding.

If the C program makes no use of the EMS Fortran interface, the `ems_link` command may be changed to `ems_link Conly`. This will avoid the linker looking for the Starlink CNF library, which may not be present at a non-Starlink site.



next up previous 204
Next: References
Up: EMS Error Message Service
Previous: C Language Interface

EMS Error Message Service
Starlink System Note 4
P C T Rees
A J Chipperfield
28 September 2001
E-mail:ussc@star.rl.ac.uk

Copyright © 2001 Council for the Central Laboratory of the Research Councils