(Last update: 08-May-2017)What follows is a description of the procedure I have followed to have CFITSIO working under Mac OS X and Linux.
I installed MacPorts downloading the "dmg" disk image installation file
corresponding to my OS Version (Snow Leopard) from here. After the installation,
one needs to execute (in order to ensure you have the latest revisions to the
"Portfiles" needed when building and installing ports):
$ sudo port -v selfupdate
Once MacPorts is available, you can trivially install many packages, in
$ sudo port install cfitsio
Note that the previous command can take several minutes if the system detects the need of installing additional packages.
Sometimes it is necessary to specify the version of the compiler. If this is
the case, you can see the list of possible variants available and execute the
installation by including the selected version:
$ port info cfitsio
$ sudo port install cfitsio +gcc6
The different versions of the CFITSIO library (libcfitsio.*) are installed under: /opt/local/lib. The auxiliary files longnam.h, fitsio.h, fitsio2.h, and drvrsmem.h are placed under: /opt/local/include. The pkg-config file is available at /opt/local/lib/pkgconfig/cfitsio.pc. Some documentation is also installed under: /opt/local/share/doc/cfitsio-3.270 (with the appropriate version number).
The different versions of the CFITSIO library (libcfitsio.*) are installed under: /usr/lib. The auxiliary files longnam.h, fitsio.h, fitsio2.h, and drvrsmem.h are placed under: /usr/include. The pkg-config file is available at /usr/lib/pkgconfig/cfitsio.pc.