[R-SIG-Mac] [External] Re: Error compiling C++ code in R 4.0 on Mac OS X Catalina

Isaac Petersen |@@@c-t-peter@en @end|ng |rom u|ow@@edu
Tue Aug 11 18:16:47 CEST 2020


Hi James and Bob,

I tried your suggestions and am attaching the output.  I wasn't able to
figure out how to run a vanilla R session, but I ran the commands in an R
session without loading any packages and without any Rprofile.site or
.Renviron files.  I removed both the Rcpp and RcppArmadillo packages and
reinstalled both from source.  Then I ran the commands.

The following command evaluated successfully (and returned the value of
"2"):
Rcpp::evalCpp("1 + 1", verbose = TRUE)

The following command did not evaluate successfully and returned an error.
I added "verbose = TRUE" to the command to provide the additional requested
output:
Rcpp::sourceCpp('/Users/itpetersen/Desktop/helloworld.cpp', verbose = TRUE)

Thanks very much for your help.
-Isaac

On Mon, Aug 10, 2020 at 7:26 PM Balamuta, James Joseph <
balamut2 using illinois.edu> wrote:

> Isaac,
>
> To build off of what Bob mentioned, you may wish to check that Rcpp and
> RcppArmadillo are indeed installed.
>
> From SO, we see:
>
> /Library/Frameworks/R.framework/Packages/RcppArmadillo/include/RcppArmadilloForward.h:26:10:
> fatal error: 'RcppCommon.h' file not found
> #include <RcppCommon.h>
>          ^~~~~~~~~~~~~~
>
> helloworld.cpp:1:10: fatal error: 'RcppArmadillo.h' file not found
> #include <RcppArmadillo.h>
>
> Both statements are indicating that the header files for Rcpp and
> RcppArmadillo are not present on the system.
>
> Could you try this minimal compilation?
>
> install.packages("Rcpp", type = "source")
> Rcpp::evalCpp("1 + 1", verbose = TRUE)
>
> Best,
>
> JJB
>
> On 8/10/20, 7:00 PM, "R-SIG-Mac on behalf of Bob Rudis" <
> r-sig-mac-bounces using r-project.org on behalf of bob using rud.is> wrote:
>
>     Something is causing Rcpp to be unable to detect the presence of
> {RcppArmadillo}, which can be seen in the lack of the include for it in the
> snippet you posted on SO (FWIW that site has multiple trackers and I'm not
> really a fan of being made a product to try to answer a question):
>
>         clang++
>           -mmacosx-version-min=10.13 \
>           -std=gnu++11 \
>           -I"/Library/Frameworks/R.framework/Resources/include" \
>           -DNDEBUG \
>           -I"/Library/Frameworks/R.framework/Packages/Rcpp/include" \
>           -I"/Users/itpetersen/Desktop" \
>           -I/usr/local/include \
>           -fPIC -Wall -g -O2  -c helloworld.cpp -o helloworld.o
>
>
>     Can you re-run the sourceRcpp() call with `verbose = TRUE` and paste
> the output here?
>
>     Also, have you tried:
>
>         remove.packages(c("Rcpp", "RcppArmadillo"))
>         install.packages(c("Rcpp", "RcppArmadillo"))
>
>     and trying everything again in a `--vanilla` R session?
>
>     > On Aug 10, 2020, at 18:33, Isaac Petersen <
> isaac-t-petersen using uiowa.edu> wrote:
>     >
>     > I'm trying to compile C++ code in R so I can install packages from
> source.
>     > I’m running R 4.0.2 on Mac OS X Catalina (10.15.6).  I receive an
> error
>     > when trying to compile C++ code in R.  I posted the full details of
> my
>     > problem on Stack Overflow here:
>     >
> https://stackoverflow.com/questions/63276265/error-compiling-c-code-in-r-4-0-on-mac-os-x-catalina?noredirect=1#comment112012438_63276265
> .
>     > The question was unfortunately marked as a duplicate because it is
> similar
>     > to another question, even though the answers to the "similar"
> question did
>     > not solve my problem.  One responder noted that
>     > "/usr/local/include/RcppArmadillo.h" was missing (even though I
>     > successfully installed the RcppArmadillo package).  Any help would be
>     > greatly appreciated.
>     >
>     > Thanks very much in advance.
>     > -Isaac
>     >
>     > ---
>     > Isaac T. Petersen, Ph.D.
>     > Assistant Professor
>     > Department of Psychological and Brain Sciences
>     > University of Iowa
>     > 175 Psychological and Brain Sciences Building
>     > Iowa City, IA 52242
>     > p: (319) 467-1014
>     > isaac-t-petersen using uiowa.edu
>     > https://psychology.uiowa.edu/developmental-psychopathology-lab
>     >
>     >   [[alternative HTML version deleted]]
>     >
>     > _______________________________________________
>     > R-SIG-Mac mailing list
>     > R-SIG-Mac using r-project.org
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>     _______________________________________________
>     R-SIG-Mac mailing list
>     R-SIG-Mac using r-project.org
>     https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20200811/5cb1b874/attachment-0001.html>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: output.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20200811/5cb1b874/attachment-0001.txt>


More information about the R-SIG-Mac mailing list