CFITSIO error compiling afw

I get an error compiling afw when calling the CFITSIO library to read an image. it lists a version mistmatch between the CFITSIO library and what afw is expecting.

I have the stack cfitsio: 3360.lsst5 installed.

[2018-01-24T17:04:11.890466Z] ==================================== ERRORS ====================================
[2018-01-24T17:04:11.890592Z] ___________________ ERROR collecting tests/test_convolve.py ____________________
[2018-01-24T17:04:11.890668Z] tests/test_convolve.py:65: in <module>
[2018-01-24T17:04:11.890773Z]     FullMaskedImage = afwImage.MaskedImageF(InputMaskedImagePath)
[2018-01-24T17:04:11.890828Z] E   FitsError:
[2018-01-24T17:04:11.891013Z] E     File "src/fits.cc", line 1270, in lsst::afw::fits::Fits::Fits(const std::string &, const std::string &, int)
[2018-01-24T17:04:11.891232Z] E       cfitsio error: could not open the named file (104) : Opening file '/Users/wmwv/lsstsw/stack/DarwinX86/afwdata/14.0+2/data/medexp.fits' with mode 'r'
[2018-01-24T17:04:11.891287Z] E   cfitsio error stack:
[2018-01-24T17:04:11.891318Z] E    {0}
[2018-01-24T17:04:11.891574Z] E   lsst::afw::fits::FitsError: 'cfitsio error: could not open the named file (104) : Opening file '/Users/wmwv/lsstsw/stack/DarwinX86/afwdata/14.0+2/data/medexp.fits' with mode 'r'
[2018-01-24T17:04:11.891631Z] E   cfitsio error stack:
[2018-01-24T17:04:11.891652Z] E   '
[2018-01-24T17:04:11.891777Z] ------------------------------- Captured stdout --------------------------------
[2018-01-24T17:04:11.891796Z]
[2018-01-24T17:04:11.891899Z] ERROR: Mismatch in the CFITSIO_SONAME value in the fitsio.h include file
[2018-01-24T17:04:11.892020Z] that was used to build the CFITSIO library, and the value in the include file
[2018-01-24T17:04:11.892103Z] that was used when compiling the application program:
[2018-01-24T17:04:11.892187Z]    Version used to build the CFITSIO library   = 2
[2018-01-24T17:04:11.892277Z]    Version included by the application program = 5
[2018-01-24T17:04:11.892295Z]
[2018-01-24T17:04:11.892400Z] Fix this by recompiling and then relinking this application program
[2018-01-24T17:04:11.892458Z] with the CFITSIO library.
[...]

afw_build.log (1.8 MB)

You have /Volumes/PS1/lsstsw/stack/DarwinX86/cfitsio/3360.lsst4-1-gf398627/bin in your PATH, contrary to the version you’re building. Perhaps you started the build in a non-clean shell?

I had a homebrew version of cfitsio that was getting picked up first in the include path (but not the library path).

I am having a similar issue with CFITSIO when trying to install the distribution. When it tries to build healpy, I get a CFITSIO error:

checking if library 'cfitsio' is installed
error: [Errno 2] No such file or directory: '/Users/jhargis/bin/lsst_stack/stack/miniconda3-4.7.12-984c9f7/DarwinX86/pykg_config/1.3.0+6/bin/pykg-config.py': '/Users/jhargis/bin/lsst_stack/stack/miniconda3-4.7.12-984c9f7/DarwinX86/pykg_config/1.3.0+6/bin/pykg-config.py'

I also have the libcfitsio.a library installed via Homebrew (located in /usr/local/lib).

build.log (295.3 KB)

Can you brew unlink cfitsio temporarily to see if that fixes the problem?

I unlinked it, but now it gives a really strange error when building:

checking for CFITSIO... yes
checking for ffgnrwll in -lcfitsio... no
configure: error: could not find the cfitsio library

The earlier steps indicate that CFITSIO was built:

[  2/121 ]  cfitsio 3360.lsst6 (already installed) done. 

I’ve attached the full build.log file below.

build.log (307.4 KB)

This file should be here although it prefers to use pkg-config anyhow.

I don’t really know anything about how healpy builds but you might want to see what’s going on with that cfitsio test in build/temp.macosx-10.9-x86_64-3.7/healpix_cxx/config.log

This problem happens when you have different version of cfitsio installed.

you need to link and configure your new software with the latest version of cfitsio you have .
First try
$ ldconfig -p | grep cfitsio
libcfitsio.so.9 (libc6,x86-64) => /usr/local/lib/libcfitsio.so.9
libcfitsio.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcfitsio.so.5
libcfitsio.so (libc6,x86-64) => /usr/local/lib/libcfitsio.so
libcfitsio.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcfitsio.so
As you see I have two versions, then copy the newest library address
before running make for installing afw
use ./configure -LDFLAGS=-L/usr/local/lib/

this will relink your new installation with the newest library in your system.

Hopefully things are easier now that we are bringing in healpy and cfitsio from conda-forge.