1 Linking with the CFITSIO Library

CFITSIO is a series of C functions, built into a object library. All C programs using the CFITSIO library will need to include the fitsio.h include file at the beginning of the program, thus:

  /* Example C program using CFITSIO */
  #include <stdio.h>
  #include "fitsio.h"
  .
  .

To compile and link a C program with the CFITSIO library, include /star/include in the include file search directives and include the command ‘cfitsio_link‘ in the list of libraries. For example (assuming you have /star/bin in your PATH):

  % cc -I/star/include -O myprog.c -o myprog -L/star/lib ‘cfitsio_link‘ -lm

On Solaris systems you will need to add -lsocket and -lnsl to the list of libraries after -lm.

The CFITSIO library can also be used from Fortran programs because each function has a Fortran wrapper routine that can be called from Fortran.

To link a Fortran program with the CFITSIO library, include the command ‘cfitsio_link‘ in your list of libraries, as for C programs. For example:

  % f77 -O myprog.f -o myprog -L/star/lib ‘cfitsio_link‘

On Solaris systems you will need to add -lsocket and -lnsl to the list of libraries after ‘cfitsio_link‘.