camb making error in mac 10.14.1

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Ding-fang Zeng
Posts: 4
Joined: December 29 2016
Affiliation: Beijing University of Technology

camb making error in mac 10.14.1

Post by Ding-fang Zeng » March 05 2019

Dear All,

Does any one hit errors of the following type when making camb(v2019-1.0.3) in mac osx(10.14.1, majave)?
... ...
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make[2]: *** [camb_exe] Error 1
make[1]: *** [../camb] Error 2
make: *** [camb] Error 2
How should I do to resolve this trouble?
Thank you in advances.
Last edited by Ding-fang Zeng on March 20 2019, edited 2 times in total.

Ding-fang Zeng
Posts: 4
Joined: December 29 2016
Affiliation: Beijing University of Technology

Re: camb making error in mac 10.14.1

Post by Ding-fang Zeng » March 20 2019

Now I know by changing the compiling command the following way, the CAMB-fortran code can be compiled successfully on my mac-majave. But I do not want to input this command line by hand every time I compile the project. How should I change the Makefile so that the option ``-L/usr/lib/'' can be added into the command automatically? Another question I want to ask is, how to change the Makefile so that I can use lldb provided by xcode to follow CAMB's running line by line? (without any revision of the Makefile, I can lldb, but cannot list source code in lldb window)

The original command is produced by the Makefile, which does not work fluently on my mac-majave+gfortran platform,
--------------------------------------------------------
gfortran -O3 -MMD -cpp -ffree-line-length-none -fmax-errors=4 -fopenmp -JRelease -IRelease/ -I"/Volumes/mac-data/dfzeng19-21/HDE-ricci/CAMB-103/fortran/../forutils/Release/" Release/inidriver.o Release/libcamb.a -L"/Volumes/mac-data/dfzeng19-21/HDE-ricci/CAMB-103/fortran/../forutils/Release/" -lforutils -o camb
--------------------------------------------------------
The proper compile command which works successfully is as follows,

********************************************************
gfortran -O3 -MMD -cpp -ffree-line-length-none -fmax-errors=4 -fopenmp -JRelease -IRelease/ -I"/Volumes/mac-data/dfzeng19-21/HDE-ricci/CAMB-103/fortran/../forutils/Release/" Release/inidriver.o Release/libcamb.a -L/usr/lib/ -L"/Volumes/mac-data/dfzeng19-21/HDE-ricci/CAMB-103/fortran/../forutils/Release/" -lforutils -o camb
********************************************************

Thanks to all

The full Makefile is as follows

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

#CAMB Makefile

#Set FISHER=Y to compile bispectrum fisher matrix code
FISHER=

#Set FORUTILSPATH to the path where the libforutils.a file can be found.
#The OUTPUT_DIR will be appended.

ifneq "$(wildcard ../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../forutils
else
ifneq "$(wildcard ../../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../../forutils
else
ifneq "$(wildcard ../../../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../../../forutils
endif
endif
endif

ifeq ($(FORUTILSPATH),)
$(error Use git clone --recurse-submodules, install forutils from https://github.com/cmbant/forutils, or set FORUTILSPATH variable)
endif

#native optimization does not work on Mac gfortran or heterogeneous clusters
CLUSTER_SAFE ?= 0
ifneq ($(CLUSTER_SAFE), 0)
NONNATIVE = 1
endif

#Will detect ifort/gfortran or edit for your compiler
ifneq ($(COMPILER),gfortran)
ifortErr = $(shell which ifort >/dev/null 2>&1; echo $$?)
else
ifortErr = 1
endif

ifeq "$(ifortErr)" "0"

#Intel compiler
F90C = ifort

ifortVer_major = $(shell ifort -v 2>&1 | cut -d " " -f 3 | cut -d. -f 1)
compiler_ver = $(shell ifort -v 2>&1)
#other tests will be done by forutils
ifeq ($(shell test $(ifortVer_major) -lt 18; echo $$?),0)
$(warning ** ifort version lower than 18.0.1 may not work with the Python wrapper **)
endif


ifeq ($(shell test $(ifortVer_major) -gt 15; echo $$?),0)
COMMON_FFLAGS = -fpp -qopenmp
else
COMMON_FFLAGS = -fpp -openmp
endif
COMMON_FFLAGS += -gen-dep=$$*.d

FFLAGS = -fp-model precise -W0 -WB $(COMMON_FFLAGS)
DEBUGFLAGS = -g -check all -check noarg_temp_created -traceback -fpe0 $(COMMON_FFLAGS)

ifeq ($(shell uname -s),Darwin)
SFFLAGS = -dynamiclib -fpic
else
SFFLAGS = -shared -fpic
endif

ifdef NONNATIVE
FFLAGS+=-O3 -ipo -axCORE-AVX2
else
FFLAGS+=-fast
endif

## This is flag is passed to the Fortran compiler allowing it to link C++ if required (not usually):
F90CRLINK = -cxxlib
ifneq "$(ifortVer_major)" "14"
F90CRLINK += -qopt-report=0 -qopt-report-phase=vec
else
F90CRLINK += -vec_report0
endif
MODOUT = -module $(OUTPUT_DIR)
AR = xiar
SMODOUT = -module $(DLL_DIR)
ifneq ($(FISHER),)
FFLAGS += -mkl
endif

else
gfortErr = $(shell which gfortran >/dev/null; echo $$?)
ifeq "$(gfortErr)" "0"
#Gfortran compiler (version 6+):
compiler_ver = $(shell gfortran -dumpversion 2>&1)
COMPILER = gfortran
F90C = gfortran
COMMON_FFLAGS = -MMD -cpp -ffree-line-length-none -fmax-errors=4 -fopenmp -L/usr/lib/
# Using -ffast-math causes differences between Debug and Release configurations.
FFLAGS = -O3 $(COMMON_FFLAGS)
DEBUGFLAGS = -g -fbacktrace -ffpe-trap=invalid,overflow,zero -fbounds-check $(COMMON_FFLAGS)
SFFLAGS = -shared -fPIC
MODOUT = -J$(OUTPUT_DIR)
SMODOUT = -J$(DLL_DIR)

ifneq ($(FISHER),)
F90CRLINK += -lblas -llapack
endif

ifeq ($(shell uname -s),Darwin)
NONNATIVE = 1
endif
ifndef NONNATIVE
#Note this seems to make code slightly slower in some cases, use CLUSTER_SAFE=1 to test without
FFLAGS+=-march=native
endif
endif
endif

IFLAG = -I

#Settings for building camb_fits
#Location of FITSIO and name of library
FITSDIR ?= /usr/local/lib
FITSLIB = cfitsio
#Location of HEALPIX for building camb_fits
HEALPIXDIR ?= /usr/local/healpix

ifneq ($(FISHER),)
# Its dependencies are all meet by the libutils.a which always added.
FFLAGS += -DFISHER
endif

DEBUGFLAGS ?= $(FFLAGS)
Debug: FFLAGS = $(DEBUGFLAGS)

include ./Makefile_main

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Post Reply