LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
141 stars 64 forks source link

Compilation error; OSx -lgcc_ext.10.4 #379

Closed alexander-mead closed 6 years ago

alexander-mead commented 6 years ago

I am currently getting an error when trying to build the latest CCL master branch. I’m running up-to-date OSx and wasn’t getting this before. The exact error is ld: library not found for -lgcc_ext.10.4. The full error is:

Mead:Physics/CCL> make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in include
make[2]: Nothing to be done for `all'.
/bin/sh ./libtool  --tag=CXX   --mode=link g++  -g -O2  -L./class -lclass -o libccl.la -rpath /usr/local/lib src/libccl_la-ccl_background.lo src/libccl_la-ccl_core.lo src/libccl_la-ccl_error.lo src/libccl_la-ccl_lsst_specs.lo src/libccl_la-ccl_placeholder.lo src/libccl_la-ccl_power.lo src/libccl_la-ccl_utils.lo src/libccl_la-ccl_cls.lo src/libccl_la-ccl_massfunc.lo src/libccl_la-ccl_neutrinos.lo src/libccl_la-ccl_emu17.lo src/libccl_la-ccl_correlation.lo src/libccl_la-fftlog.lo  class/libclass.a -lfftw3 -lgsl -lgslcblas 

*** Warning: Linking the shared library libccl.la against the
*** static library class/libclass.a is not portable!
libtool: link: g++ -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libccl.0.dylib  src/.libs/libccl_la-ccl_background.o src/.libs/libccl_la-ccl_core.o src/.libs/libccl_la-ccl_error.o src/.libs/libccl_la-ccl_lsst_specs.o src/.libs/libccl_la-ccl_placeholder.o src/.libs/libccl_la-ccl_power.o src/.libs/libccl_la-ccl_utils.o src/.libs/libccl_la-ccl_cls.o src/.libs/libccl_la-ccl_massfunc.o src/.libs/libccl_la-ccl_neutrinos.o src/.libs/libccl_la-ccl_emu17.o src/.libs/libccl_la-ccl_correlation.o src/.libs/libccl_la-fftlog.o   -L./class -lclass class/libclass.a -lfftw3 -lgsl -lgslcblas  -g -O2   -install_name  /usr/local/lib/libccl.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-single_module
g++: warning: couldn't understand kern.osversion '17.5.0
ld: library not found for -lgcc_ext.10.4
collect2: error: ld returned 1 exit status
make[2]: *** [libccl.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Am I doing something daft?

alexander-mead commented 6 years ago

Okay, this seemed to be some strange OSx-related error to do with the Xcode C or C++ compiler (which I think is called clang). I was able to circumvent it by demanding that CCL used my homebrew installs of gcc and g++ instead via:

./configure CC=gcc-8 CXX=g++-8

Now I can compile the latest master branch and all the test pass, which is nice.

tmcclintock commented 6 years ago

You are correct, the default C/C++ compiler on Macs is called clang. And when you use gcc on a mac terminal, it is secretly calling clang, and not gcc. Nice job figuring this out :).

alexander-mead commented 6 years ago

I also had to do a similar issue with the python installation, where the C compiler once again defaulted to clang rather than gcc. I guess I was always using clang before and I suppose I must have screwed up my clang installation somehow, but I don't know why this only manifested itself when I pulled the latest branch.

Both of these things could be solved simultaneously by me setting the environment variables CC=gcc-8 and CXX=g++-8, which previously I had not set.

More hours of my life I will never get back.