I got a new computer, running OS X 10.11.3. I installed Xcode from the App Store, and installed Rcpp. But something isn't set up right with the C compiler, and I'm getting errors whenever I try to run Rcpp:
> library(Rcpp)
> evalCpp("2 + 2")
clang: error: no such file or directory: '/usr/local/lib/libcairo.a'
clang: error: no such file or directory: '/usr/local/lib/libpixman-1.a'
clang: error: no such file or directory: '/usr/local/lib/libfreetype.a'
clang: error: no such file or directory: '/usr/local/lib/libfontconfig.a'
clang: error: no such file or directory: '/usr/local/lib/libreadline.a'
make: *** [sourceCpp_85133.so] Error 1
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I"/private/var/folders/jj/mgcsjjw10sbfhdtb9x2zsry00000gn/T/RtmpVd8HCA" -fPIC -Wall -mtune=core2 -g -O2 -c file151214b93abd.cpp -o file151214b93abd.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/X11/lib -L/usr/local/lib /usr/local/lib/libcairo.a /usr/local/lib/libpixman-1.a /usr/local/lib/libfreetype.a /usr/local/lib/libfontconfig.a -lxml2 /usr/local/lib/libreadline.a -o sourceCpp_85133.so file151214b93abd.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
Any suggestions?
You probably have a local Makevars (e.g. at ~/.R/Makevars) that has these bogus LDFLAG entries. (That, or the R Makeconf, or maybe you have Homebrew R without the requisite libraries installed as well, or ...)
Concur and will close accordingly. If this can be reduced to a reproducible example showing that Rcpp on OS X fails -- which is unlikely given that some Rcpp Core folks develop on that platform -- please feel free to reopen.
Hi, thanks for the comments. I do in fact have a local Makevars file, but the only lines it has in it are
CC=clang
CXX=clang++
I don't know what you mean by Makeconf. I should have mentioned before that I am running Microsoft R Open (3.2.4), I'm not sure if that affects anything, but I didn't see anything online indicating it would.
I found this post online, which suggests the above contents for the Makevars file. It also suggests installing Rcpp with source = TRUE, but when I did that I got similar error messages to those listed above:
> install.packages("Rcpp", type = "source")
trying URL 'https://mran.revolutionanalytics.com/snapshot/2016-04-01/src/contrib/Rcpp_0.12.4.tar.gz'
Content type 'application/octet-stream' length 2402065 bytes (2.3 MB)
==================================================
downloaded 2.3 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c Date.cpp -o Date.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c Module.cpp -o Module.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c api.cpp -o api.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c attributes.cpp -o attributes.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c barrier.cpp -o barrier.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/X11/lib -L/usr/local/lib /usr/local/lib/libcairo.a /usr/local/lib/libpixman-1.a /usr/local/lib/libfreetype.a /usr/local/lib/libfontconfig.a -lxml2 /usr/local/lib/libreadline.a -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
clang: error: no such file or directory: '/usr/local/lib/libcairo.a'
clang: error: no such file or directory: '/usr/local/lib/libpixman-1.a'
clang: error: no such file or directory: '/usr/local/lib/libfreetype.a'
clang: error: no such file or directory: '/usr/local/lib/libfontconfig.a'
clang: error: no such file or directory: '/usr/local/lib/libreadline.a'
make: *** [Rcpp.so] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp’
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/jj/mgcsjjw10sbfhdtb9x2zsry00000gn/T/RtmpdvEQtS/downloaded_packages’
Sorry if any of these questions are dumb, but I am new to Rcpp, so any further suggestions on how I could diagnose this problem would be appreciated.
I don't know what you mean by Makeconf.
Find your R installation directory. Look it into its subdirectory etc/, it will have a file Makeconf.
Programmatically:
file.show(file.path(R.home(), "etc", "Makeconf"))
thanks, here's what it lists for LDFLAGS:
LDFLAGS = -L/opt/X11/lib -L/usr/local/lib /usr/local/lib/libcairo.a /usr/local/lib/libpixman-1.a /usr/local/lib/libfreetype.a /usr/local/lib/libfontconfig.a -lxml2 /usr/local/lib/libreadline.a
Should I remove them? What should be there?
Should I remove them?
Yes.
What should be there?
Whatever is needed on your system. That they are there now is an indication that something went belly-up with the binary you are using. Talk to its creator.
Still not _our bug or issue_ here.
Are you using Microsoft R Open? Are they shipping an R binary that expects you to have these libraries installed in /usr/local/lib? If so, you probably want to bring it up with them. (inferring this based on your use of the MRAN repositories)
Thanks guys for all your help (esp. on a Sunday night)! Removing those entries from LDFLAGS fixed the problem. I can't remember why I added them in the first place.
Most helpful comment
You probably have a local Makevars (e.g. at
~/.R/Makevars) that has these bogusLDFLAGentries. (That, or the RMakeconf, or maybe you have Homebrew R without the requisite libraries installed as well, or ...)