Troubles installing rsocsim on Mac (compilation)
Closed this issue · 6 comments
Hi Tom, I tried installing rsocsim
for the first time, but received error messages (see console output below) and couldn't complete the installation. I use MacOS Ventura 13.4, RStudio Version 2023.06.0+421, and R 4.3.1. Also, I checked that I have devtools
as well as Xcode (Version 14.3.1) installed and updated. Your help is very much appreciated! Thanks, Bettina
> library(devtools)
Loading required package: usethis
> devtools::install_github("MPIDR/rsocsim")
Downloading GitHub repo MPIDR/rsocsim@HEAD
Error: Failed to install 'rsocsim' from GitHub:
Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘clang version 7.0.0 (tags/RELEASE_700/final)’
using SDK: ‘’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c foo.c -o foo.o
warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: building for iOS 5.0.0 is deprecated
ld: framework not found CoreFoundation
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [foo.so] Error 1
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
This is tricky. You seem to have installed all prerequisites, but R still can't "find the necessary tools to compile a package".
Can you try to run pkgbuild::check_build_tools(debug = TRUE)
and post the output of that command here?
Hi Tom, thanks for your message. Here is the output you requested:
> library(devtools)
Loading required package: usethis
> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘clang version 7.0.0 (tags/RELEASE_700/final)’
using SDK: ‘’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c foo.c -o foo.o
warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: building for iOS 5.0.0 is deprecated
ld: framework not found CoreFoundation
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [foo.so] Error 1
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
Thanks for your help!
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘clang version 7.0.0 (tags/RELEASE_700/final)’
using SDK: ‘’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c foo.c -o foo.o
clang-7: warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
-iphoneos_version_min has been renamed to -ios_version_min
ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
ld: warning: -undefined dynamic_lookup is deprecated on iOS
-iphoneos_version_min has been renamed to -ios_version_min
ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
ld: warning: -undefined dynamic_lookup is deprecated on iOS
dyld[10649]: missing symbol called
clang-7: error: unable to execute command: Abort trap: 6
clang-7: error: linker command failed due to signal (use -v to see invocation)
make: *** [foo.so] Error 254
R finds a compiler (I guess), but it is maybe wrongly configured...
After some googling these are the steps I would try next:
- Try the (small) fix from this answer on Stackoverflow, although their problem was a bit different: https://stackoverflow.com/questions/70735301/rcpp-does-not-compile-on-mac-os-monterey-r-4-1-2-clang-error
- Follow this guide to remove a previous installation and then install the necessary compilertools for Rcpp (Rcpp is the library that rsocsim uses under the hood): https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/
Hi Tom, the problem was solved with the code from the first link! Thanks so much -- first simulation is already up and running now :))
That is great to hear!