In some cases, you may get an error that does not allow installation of goldfish from source on Mac OSX versions, including under R 4.0.0. The error may relate to compiling the parts of goldfish that are written in C++, or whether OpenMP (for parallelisation) can be found. To install OpenMP, follow these steps:
gcc
via the terminal command brew install gcc
. gcc
you have with: brew list --versions gcc
~/.R
and open the file Makevars
. Add the following code to that file:CC=/usr/local/bin/gcc-10
CXX=/usr/local/bin/g++-10
CXX1X=/usr/local/bin/g++-10
CXX11=/usr/local/bin/g++-10
SHLIB_CXXLD=/usr/local/bin/g++-10
FC=/usr/local/bin/gfortran-10
F77=/usr/local/bin/gfortran-10
MAKE=make -j8
SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp
If you do not have version 10 of gcc
, replace all the 10s in the code above with your version number.
/Library/Frameworks/R.framework/Resources/etc/
and open the file Makeconf
. Here you need to
add the library path to SHLIB_LIBADD
: SHLIB_LIBADD = -L/usr/local/lib
If you are using an M1, M2, ... machine, you could follow the previous instructions to install a gcc
compiler and setting up the compilers for R
.
Thanks to @eugeniagilpa, here there is an alternative version of the Makevars
file that should work for M1, M2, ... machines:
XCBASE:=$(shell xcrun --show-sdk-path)
GCCBASE:=$(shell brew --prefix gcc)
GETTEXT:=$(shell brew --prefix gettext)
CC=$(GCCBASE)/bin/gcc-13
CXX=$(GCCBASE)/bin/g++-13
CXX11=$(GCCBASE)/bin/g++-13
CXX14=$(GCCBASE)/bin/g++-13
CXX17=$(GCCBASE)/bin/g++-13
CXX20=$(GCCBASE)/bin/g++-13
CXX23=$(GCCBASE)/bin/g++-13
SHLIB_CXXLD=$(GCCBASE)/bin/g++-13
FC=$(GCCBASE)/bin/gfortran
F77=$(GCCBASE)/bin/gfortran
FLIBS=-L/$(GCCBASE)/lib/gcc/13/ -lm -lgfortran
CPPFLAGS=-isystem "$(GCCBASE)/include" -isysroot "$(XCBASE)"
LDFLAGS=-L"$(GCCBASE)/lib" -L"$(GETTEXT)/lib" --sysroot="$(XCBASE)"
MAKE=make -j8
SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp
SHLIB_CXXLDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXXFLAGS) $(CXXPICFLAGS) $(LTO_LD)
SHLIB_CXX11LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXX11FLAGS) $(CXX11PICFLAGS) $(LTO_LD)
SHLIB_CXX14LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXX14FLAGS) $(CXX14PICFLAGS) $(LTO_LD)
SHLIB_CXX17LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXX17FLAGS) $(CXX17PICFLAGS) $(LTO_LD)
SHLIB_CXX20LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXX20FLAGS) $(CXX20PICFLAGS) $(LTO_LD)
SHLIB_CXX23LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CXX23FLAGS) $(CXX23PICFLAGS) $(LTO_LD)
SHLIB_FCLDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(FCFLAGS) $(FPICFLAGS)
SHLIB_LDFLAGS = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CFLAGS) $(CPICFLAGS) $(LTO_LD)
SHLIB_LDFLAGS_R = -dynamiclib -Wl,-ld_classic,-headerpad_max_install_names -undefined dynamic_lookup $(CFLAGS) $(CPICFLAGS) $(LTO_LD)
In step 5 the path to the library should be:
SHLIB_LIBADD = -L/opt/homebrew/opt/gfortran/lib
Please share feedback on which of these work (shortcuts or unnecessary parts) and we will update the installation guide accordingly.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.