Issues with c++ and brms_multiple

Hello! I am trying to fit multilevel models with brms using multiply imputed data. However, I am running into issues using even the sample data and code. For example, when I run this:

library(mice)
library(brms)
imp <- mice(nhanes2)

fit_imp2 <- brm_multiple(bmi ~ age + hyp + chl, data = imp, chains = 1)

I get this:

> fit_imp2 <- brm_multiple(bmi ~ age + hyp + chl, data = imp, chains = 1)
Compiling the C++ model
make cmd is
  make -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file1679678d6d81d.so' OBJECTS='file1679678d6d81d.o'

make would use
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fPIC  -Wall -g -O2  -c file1679678d6d81d.cpp -o file1679678d6d81d.o
if test  "zfile1679678d6d81d.o" != "z"; then \
	  echo clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file1679678d6d81d.so file1679678d6d81d.o  '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	  clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file1679678d6d81d.so file1679678d6d81d.o  '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/SparseExtra:51:/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/../../Eigen/src/Core/util/ReenableStupidWarnings.h:14:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]    #pragma clang diagnostic pop                             ^21 warnings and 1 error generated.make: *** [file1679678d6d81d.o] Error 1
Error in sink(type = "output") : invalid connection

I am ultimately trying to run this over a server (I am having the same issue there), but trying to figure it out just on my own computer first. Thank you!

Are you able to run any brms or rstan models? Or is it just brm_multiple that gives this error?

For example, are there any errors with the rstan example model:

example(stan_model,package="rstan",run.dontrun=T)
1 Like

Thank you so much for replying!! Interestingly, I am able to run other brms models fine on the server Iā€™m working on (Iā€™ve fit various multilevel models with no issue), itā€™s only brms_multiple that gives me issues. However, on my personal computer, I am unable to run any brms or rstan models; I also just tried uninstalling and re-installing brms/rstan and am still getting errors:

install.packages(ā€œbrmsā€)
also installing the dependency ā€˜rstanā€™

There is a binary version available but the source version is later:
binary source needs_compilation
rstan 2.21.1 2.21.2 TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) no
trying URL ā€˜https://cran.rstudio.com/bin/macosx/contrib/4.0/rstan_2.21.1.tgzā€™
Content type ā€˜application/x-gzipā€™ length 24875244 bytes (23.7 MB)

downloaded 23.7 MB

trying URL ā€˜https://cran.rstudio.com/bin/macosx/contrib/4.0/brms_2.14.4.tgzā€™
Content type ā€˜application/x-gzipā€™ length 5859145 bytes (5.6 MB)

downloaded 5.6 MB

The downloaded binary packages are in
/var/folders/zp/jpfw8ld93256q1p35t5ntc8m0000gp/T//Rtmpfuix3n/downloaded_packages

install.packages(ā€œrstanā€)

There is a binary version available but the source version is later:
binary source needs_compilation
rstan 2.21.1 2.21.2 TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) no
trying URL ā€˜https://cran.rstudio.com/bin/macosx/contrib/4.0/rstan_2.21.1.tgzā€™
Content type ā€˜application/x-gzipā€™ length 24875244 bytes (23.7 MB)

downloaded 23.7 MB

The downloaded binary packages are in
/var/folders/zp/jpfw8ld93256q1p35t5ntc8m0000gp/T//Rtmpfuix3n/downloaded_packages

library(brms)
Loading ā€˜brmsā€™ package (version 2.14.4). Useful instructions
can be found by typing help(ā€˜brmsā€™). A more detailed introduction
to the package is available through vignette(ā€˜brms_overviewā€™).

Attaching package: ā€˜brmsā€™

The following object is masked from ā€˜package:statsā€™:

ar

library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.1, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
example(stan_model,package=ā€œrstanā€,run.dontrun=T)

stn_md> stancode ā† ā€˜data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}ā€™

stn_md> mod ā† stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ā€˜16a540c6086086816528e4524def24d9ā€™ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ā€˜16a540c6086086816528e4524def24d9ā€™.
sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues Ā· stan-dev/stanc3 Ā· GitHub
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
COMPILING THE C++ CODE FOR MODEL ā€˜16a540c6086086816528e4524def24d9ā€™ NOW.
OS: x86_64, darwin17.0; rstan: 2.21.1; Rcpp: 1.0.6; inline: 0.3.16

(then a whole lot of text ā€¦ and then:)

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/SparseExtra:51:/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported/Eigen/ā€¦/ā€¦/Eigen/src/Core/util/ReenableStupidWarnings.h:14:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas] #pragma clang diagnostic pop ^21 warnings and 1 error generated.make: *** [file16c752380f8c6.o] Error 1
In addition: Warning messages:
1: In system2(CXX, args = ARGS) : error in running command
2: In file.remove(c(unprocessed, processed)) :
cannot remove file ā€˜/var/folders/zp/jpfw8ld93256q1p35t5ntc8m0000gp/T//Rtmpfuix3n/file16c755418e75e.stanā€™, reason ā€˜No such file or directoryā€™

Unfortunately that doesnā€™t contain an error message I can debug (only warnings). Can you run the example with the verbose flag:

example(stan_model,package="rstan",run.dontrun=T,verbose=T)

And post as much of the output as possible? If thereā€™s a lot, you can just copy it to a text file and upload that

Of course, thank you! Please see attached :) brms errors.txt (38.0 KB)

Hmm, nothing useful there. Letā€™s check if you can compile C++ at all, can you see if you can run the example model from the inline package:

example(cxxfunction, package = "inline", run.dontrun = TRUE)

example(cxxfunction, package = ā€œinlineā€, run.dontrun = TRUE)

Attaching package: ā€˜inlineā€™

The following object is masked from ā€˜package:Rcppā€™:

registerPlugin

cxxfnc> # default plugin
cxxfnc> fx ā† cxxfunction( signature(x = ā€œintegerā€, y = ā€œnumericā€ ) , ā€™
cxxfnc+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
cxxfnc+ ā€™ )

cxxfnc> fx( 2L, 5 )
[1] 10

cxxfnc> # Rcpp plugin
cxxfnc> if( require( Rcpp ) ){
cxxfnc+
cxxfnc+ fx ā† cxxfunction( signature(x = ā€œintegerā€, y = ā€œnumericā€ ) , ā€™
cxxfnc+ return wrap( as(x) * as(y) ) ;
cxxfnc+ ', plugin = ā€œRcppā€ )
cxxfnc+ fx( 2L, 5 )
cxxfnc+
cxxfnc+ ## equivalent shorter form using rcpp()
cxxfnc+ fx ā† rcpp(signature(x = ā€œintegerā€, y = ā€œnumericā€),
cxxfnc+ ā€™ return wrap( as(x) * as(y) ) ; ')
cxxfnc+
cxxfnc+ }

cxxfnc> # RcppArmadillo plugin
cxxfnc> if( require( RcppArmadillo ) ){
cxxfnc+
cxxfnc+ fx ā† cxxfunction( signature(x = ā€œintegerā€, y = ā€œnumericā€ ) , ā€™
cxxfnc+ int dim = as( x ) ;
cxxfnc+ arma::mat z = as(y) * arma::eyearma::mat( dim, dim ) ;
cxxfnc+ return wrap( arma::accu(z) ) ;
cxxfnc+ ', plugin = ā€œRcppArmadilloā€ )
cxxfnc+ fx( 2L, 5 )
cxxfnc+
cxxfnc+
cxxfnc+ }
Loading required package: RcppArmadillo

ERROR(s) during compilation: source code errors or compiler configuration errors!
make cmd is
make -f ā€˜/Library/Frameworks/R.framework/Resources/etc/Makeconfā€™ -f ā€˜/Library/Frameworks/R.framework/Resources/share/make/shlib.mkā€™ SHLIB_LDFLAGS=ā€˜(SHLIB_CXXLDFLAGS)' SHLIB_LD='(SHLIB_CXXLD)ā€™ SHLIB=ā€˜file16de61f2e7e65.soā€™ OBJECTS=ā€˜file16de61f2e7e65.oā€™

make would use
if test ā€œzfile16de61f2e7e65.oā€ != ā€œzā€; then
echo clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file16de61f2e7e65.so file16de61f2e7e65.o -L"/Library/Frameworks/R.framework/Resources/lib" -lRlapack -L"/Library/Frameworks/R.framework/Resources/lib" -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/ā€¦ -framework R -Wl,-framework -Wl,CoreFoundation;
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file16de61f2e7e65.so file16de61f2e7e65.o -L"/Library/Frameworks/R.framework/Resources/lib" -lRlapack -L"/Library/Frameworks/R.framework/Resources/lib" -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/ā€¦ -framework R -Wl,-framework -Wl,CoreFoundation;
fi

Program source:
1:
2: // includes from the plugin
3: #include <RcppArmadillo.h>
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17: // user includes
18:
19:
20: // declarations
21: extern ā€œCā€ {
22: SEXP file16de61f2e7e65( SEXP x, SEXP y) ;
23: }
24:
25: // definition
26:
27: SEXP file16de61f2e7e65( SEXP x, SEXP y ){
28: BEGIN_RCPP
29:
30: int dim = as( x ) ;
31: arma::mat z = as(y) * arma::eyearma::mat( dim, dim ) ;
32: return wrap( arma::accu(z) ) ;
33:
34: END_RCPP
35: }
36:
37:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
In file included from file16de61f2e7e65.cpp:3:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/RcppArmadillo.h:34:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable ā€˜dataā€™ [-Wunused-variable] SEXP data = Parent::get__(); ^1 warning generated.ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0ā€™ld: warning: directory not found for option '-L/usr/local/gfortran/libā€™ld: library not found for -lgfortranclang: error: linker command failed with exit code 1 (use -v to see invocation)make: *** [file16de61f2e7e65.so] Error 1

Alright, so it looks like your compiler toolchain isnā€™t setup quite right. As one final test, are you able to compile packages from source?

Try:

install.packages("jsonlite",type="source")

This is what I get from trying to install (I think it worked?) :

install.packages(ā€œjsonliteā€,type=ā€œsourceā€)
Error in install.packages : Updating loaded packages

Restarting R sessionā€¦

install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
Error in install.packages : Updating loaded packages

Restarting R sessionā€¦

install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
Error in install.packages : Updating loaded packages

Restarting R sessionā€¦

install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
Error in install.packages : Updating loaded packages

Restarting R sessionā€¦

install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
Error in install.packages : Updating loaded packages

Restarting R sessionā€¦

install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
Error in install.packages : Updating loaded packages
install.packages(ā€œjsonliteā€, type = ā€œsourceā€)
trying URL ā€˜https://cran.rstudio.com/src/contrib/jsonlite_1.7.2.tar.gzā€™
Content type ā€˜application/x-gzipā€™ length 421716 bytes (411 KB)
==================================================
downloaded 411 KB

  • installing source package ā€˜jsonliteā€™ ā€¦
    ** package ā€˜jsonliteā€™ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c base64.c -o base64.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c collapse_array.c -o collapse_array.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c collapse_object.c -o collapse_object.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c collapse_pretty.c -o collapse_pretty.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c escape_chars.c -o escape_chars.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c integer64_to_na.c -o integer64_to_na.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c is_datelist.c -o is_datelist.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c is_recordlist.c -o is_recordlist.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c is_scalarlist.c -o is_scalarlist.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c modp_numtoa.c -o modp_numtoa.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c null_to_na.c -o null_to_na.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c num_to_char.c -o num_to_char.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c parse.c -o parse.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c prettify.c -o prettify.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c push_parser.c -o push_parser.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c r-base64.c -o r-base64.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c register.c -o register.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c row_collapse.c -o row_collapse.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c transpose_list.c -o transpose_list.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c validate.c -o validate.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl.c -o yajl/yajl.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_alloc.c -o yajl/yajl_alloc.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_buf.c -o yajl/yajl_buf.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_encode.c -o yajl/yajl_encode.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_gen.c -o yajl/yajl_gen.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_lex.c -o yajl/yajl_lex.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_parser.c -o yajl/yajl_parser.o
    clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iyajl/api -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c yajl/yajl_tree.c -o yajl/yajl_tree.o
    ar rcs yajl/libstatyajl.a yajl/yajl.o yajl/yajl_alloc.o yajl/yajl_buf.o yajl/yajl_encode.o yajl/yajl_gen.o yajl/yajl_lex.o yajl/yajl_parser.o yajl/yajl_tree.o
    clang -mmacosx-version-min=10.13 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o jsonlite.so base64.o collapse_array.o collapse_object.o collapse_pretty.o escape_chars.o integer64_to_na.o is_datelist.o is_recordlist.o is_scalarlist.o modp_numtoa.o null_to_na.o num_to_char.o parse.o prettify.o push_parser.o r-base64.o register.o row_collapse.o transpose_list.o validate.o -Lyajl -lstatyajl -F/Library/Frameworks/R.framework/ā€¦ -framework R -Wl,-framework -Wl,CoreFoundation
    installing to /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-jsonlite/00new/jsonlite/libs
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    in method for ā€˜asJSONā€™ with signature ā€˜ā€œblobā€ā€™: no definition for class ā€œblobā€
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    ** checking absolute paths in shared objects and dynamic libraries
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • DONE (jsonlite)

The downloaded source packages are in
ā€˜/private/var/folders/zp/jpfw8ld93256q1p35t5ntc8m0000gp/T/RtmpC5c12W/downloaded_packagesā€™

Hmm so that works, strange. Alright, weā€™ll try a different c++ test to make sure that the previous wasnā€™t caused by something else. What do you get from:

system("touch foo.cpp")
system("R CMD SHLIB foo.cpp")

Seriously thank you for all this help! This is what I get:

system(ā€œtouch foo.cppā€)
system(ā€œR CMD SHLIB foo.cppā€)
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iā€¦/inst/include -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c foo.cpp -o foo.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o foo.so foo.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/ā€¦ -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option ā€˜-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0ā€™
ld: warning: directory not found for option ā€˜-L/usr/local/gfortran/libā€™
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [foo.so] Error 1

Converselyserver.txt (5.5 KB) , Iā€™ve attached what happens on the server (brms works fine, brms_multiple gets stuck)

Yep it looks like a toolchain issue here. Unfortunately Iā€™m completely unfamiliar with Macs so I canā€™t debug past this point. Iā€™ll just tag someone thatā€™s quite experienced on the Mac side of things!

@torkar is this something that youā€™ve seen before or know how to fix/debug?

thank you for your help and for trying!!

1 Like

Fishyā€¦

ld: warning: directory not found for option ā€˜-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0ā€™
ld: warning: directory not found for option ā€˜-L/usr/local/gfortran/libā€™

The above indicates that something is pointing to the wrong directory. @hermione what do you get when you type this in R:

system("cat ~.R/Makevars") 
system("cat ~/.Rprofile") 
system("cat ~/.Renviron")
1 Like

This is the output: looks like I donā€™t have some directories set up?

system(ā€œcat ~.R/Makevarsā€)
cat: ~.R/Makevars: No such file or directory
system(ā€œcat ~/.Rprofileā€)
cat: /Users/abeccia/.Rprofile: No such file or directory
system(ā€œcat ~/.Renvironā€)
cat: /Users/abeccia/.Renviron: No such file or directory

What if you do this:

system("ls /usr/local/gfortran")
system("ls /usr/local/gfortran/lib/gcc/")

system(ā€œls /usr/local/gfortranā€)
ls: /usr/local/gfortran: No such file or directory
system(ā€œls /usr/local/gfortran/lib/gcc/ā€)
ls: /usr/local/gfortran/lib/gcc/: No such file or directory

Seems you havenā€™t installed gfortran. If you have Big Sur please download and install this: https://github.com/fxcoudert/gfortran-for-macOS/releases/download/10.2-bigsur-intel/gfortran-10.2-BigSur-Intel.dmg

Once installed, add a file Makevars in the director .R/ with the following content:

FC=/usr/bin/gfortran
F77=/usr/bin/gfortran 
FLIBS=/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0/

Then restart R/RStudio.

[EDIT: Changed to the Big Sur gfortran link]

thank you so much, I will try this and let you know if it works. Do you happen to have any ideas about my issues in using brms_multiple over a server (Linux based)? I can run the brms models fine but brms_multiple just hangs on Compiling the C++ model.

What output do you get when you run brm_multiple with the verbose=T option?

Also, you could try installing cmdstanr (instructions here) and running your model with the backend="cmdstanr" option