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

Balamuta, James Joseph b@|@mut2 @end|ng |rom ||||no|@@edu
Tue Aug 11 02:26:47 CEST 2020


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



More information about the R-SIG-Mac mailing list