Closed bhogan-mitre closed 5 years ago
Can you run it with debug = TRUE
, e.g. pkgbuild::has_compiler(debug = TRUE)
?
Also Rcpp is a C++ package and has_compiler()
is checking C compilation, so it is possible that your C compiler is not working but the C++ one is.
Thanks for the follow up.
> pkgbuild::has_compiler(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c foo.c -o foo.o
CFLAGS=-g: No such file or directory
make: *** [foo.o] Error 127
[1] FALSE
Let me know if there is a better test of the setup for C compilation.
You seem to have no compiler set, did you change the CC
environment variable?
I hadn't changed it, or intentionally set it either.
> Sys.getenv("CC")
[1] ""
Explicitly setting to clang
did not seem to make a difference.
> Sys.setenv(CC = "/usr/local/opt/llvm/bin/clang")
> Sys.getenv("CC")
[1] "/usr/local/opt/llvm/bin/clang"
> pkgbuild::has_compiler(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c foo.c -o foo.o
CFLAGS=-g: No such file or directory
make: *** [foo.o] Error 127
[1] FALSE
Here is one clue as to the disconnect: calling which clang
from R returns a different result than from a terminal (even the RStudio terminal).
> system("which clang")
/usr/bin/clang
vs.
bhogan$ which clang
/usr/local/opt/llvm/bin/clang
Okay, I am back in business here.
> pkgbuild::has_compiler(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c foo.c -o foo.o
clang -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 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
[1] TRUE
Nothing needed to change with the compiler itself. I just had a lingering old ~/.R/Makevars
around, presumably from an old Xcode install. This Q&A did the trick https://stackoverflow.com/a/49268991/4425601
I am having a disconnect with the result of
has_compiler
. Are there some environment variables that need to be set in order for this to work properly?has_compiler
shows false:But yet I can install packages from source, for example
Rcpp
:Session info:
Thanks for any suggestions you could provide.