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 <
balam...@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-boun...@r-project.org on behalf of b...@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-peter...@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-peter...@uiowa.edu
>     > https://psychology.uiowa.edu/developmental-psychopathology-lab
>     >
>     >   [[alternative HTML version deleted]]
>     >
>     > _______________________________________________
>     > R-SIG-Mac mailing list
>     > R-SIG-Mac@r-project.org
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>     _______________________________________________
>     R-SIG-Mac mailing list
>     R-SIG-Mac@r-project.org
>     https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> .libPaths("/Library/Frameworks/R.Framework/Packages")
> remove.packages(c("Rcpp", "RcppArmadillo"))
Removing packages from ‘/Library/Frameworks/R.framework/Packages’
(as ‘lib’ is unspecified)
> install.packages(c("Rcpp", "RcppArmadillo"), type = "source")
Installing packages into ‘/Library/Frameworks/R.framework/Packages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.5.tar.gz'
Content type 'application/x-gzip' length 2950521 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

trying URL 
'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.9.900.2.0.tar.gz'
Content type 'application/x-gzip' length 1645254 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c api.cpp -o 
api.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c 
attributes.cpp -o attributes.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c barrier.cpp 
-o barrier.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c date.cpp -o 
date.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c module.cpp 
-o module.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I../inst/include/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c 
rcpp_init.cpp -o rcpp_init.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -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 Rcpp.so api.o attributes.o barrier.o date.o module.o 
rcpp_init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
-Wl,CoreFoundation
installing to 
/Library/Frameworks/R.framework/Packages/00LOCK-Rcpp/00new/Rcpp/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Rcpp)
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -mmacosx-version-min=10.13 -std=gnu++11 accepts -g... 
yes
checking how to run the C++ preprocessor... clang++ -mmacosx-version-min=10.13 
-std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ -mmacosx-version-min=10.13 -std=gnu++11 accepts -g... 
(cached) yes
checking whether we have a suitable tempdir... 
/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T
checking whether R CMD SHLIB can already compile programs using OpenMP... no
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC 
extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... not found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
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/usr/local/include  
-I../inst/include  -fPIC  -Wall -g -O2  -c RcppArmadillo.cpp -o RcppArmadillo.o
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/usr/local/include  
-I../inst/include  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
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/usr/local/include  
-I../inst/include  -fPIC  -Wall -g -O2  -c fastLm.cpp -o fastLm.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -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 RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o 
-L/Library/Frameworks/R.framework/Resources/lib -lRlapack 
-L/Library/Frameworks/R.framework/Resources/lib -lRblas 
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 
-L/usr/local/gfortran/lib -lgfortran -lquadmath -lm 
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
-Wl,CoreFoundation
installing to 
/Library/Frameworks/R.framework/Packages/00LOCK-RcppArmadillo/00new/RcppArmadillo/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (RcppArmadillo)

The downloaded source packages are in
        
‘/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/downloaded_packages’
> Rcpp::evalCpp("1 + 1", verbose = TRUE)

Generated code for function definition: 
--------------------------------------------------------

#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::export]]
SEXP get_value(){ return wrap( 1 + 1 ) ; }

Generated extern "C" functions 
--------------------------------------------------------


#include <Rcpp.h>
// get_value
SEXP get_value();
RcppExport SEXP sourceCpp_1_get_value() {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    rcpp_result_gen = Rcpp::wrap(get_value());
    return rcpp_result_gen;
END_RCPP
}

Generated R functions 
-------------------------------------------------------

`.sourceCpp_1_DLLInfo` <- 
dyn.load('/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/sourceCpp-x86_64-apple-darwin17.0-1.0.5/sourcecpp_275a2a9c550c/sourceCpp_2.so')

get_value <- Rcpp:::sourceCppFunction(function() {}, FALSE, 
`.sourceCpp_1_DLLInfo`, 'sourceCpp_1_get_value')

rm(`.sourceCpp_1_DLLInfo`)

Building shared library
--------------------------------------------------------

DIR: 
/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/sourceCpp-x86_64-apple-darwin17.0-1.0.5/sourcecpp_275a2a9c550c

/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB -o 'sourceCpp_2.so' 
'file275a5799aeb2.cpp' 
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"/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/sourceCpp-x86_64-apple-darwin17.0-1.0.5"
 -I/usr/local/include   -fPIC  -Wall -g -O2  -c file275a5799aeb2.cpp -o 
file275a5799aeb2.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -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 sourceCpp_2.so file275a5799aeb2.o 
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
-Wl,CoreFoundation
[1] 2
> Rcpp::sourceCpp('/Users/itpetersen/Desktop/helloworld.cpp', verbose = TRUE)

Generated extern "C" functions 
--------------------------------------------------------


#include <Rcpp.h>

Generated R functions 
-------------------------------------------------------

`.sourceCpp_3_DLLInfo` <- 
dyn.load('/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/sourceCpp-x86_64-apple-darwin17.0-1.0.5/sourcecpp_275a7d939cae/sourceCpp_4.so')


rm(`.sourceCpp_3_DLLInfo`)

Building shared library
--------------------------------------------------------

DIR: 
/private/var/folders/p5/tkdpnffs2_g5ybr2t1yq1nd0rq_9pt/T/Rtmp3PiDrA/sourceCpp-x86_64-apple-darwin17.0-1.0.5/sourcecpp_275a7d939cae

/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB -o 'sourceCpp_4.so' 
'helloworld.cpp' 
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
helloworld.cpp:1:10: fatal error: 'RcppArmadillo.h' file not found
#include <RcppArmadillo.h>   
         ^~~~~~~~~~~~~~~~~
1 error generated.
make: *** [helloworld.o] Error 1
Error in Rcpp::sourceCpp("/Users/itpetersen/Desktop/helloworld.cpp", verbose = 
TRUE) : 
  Error 1 occurred building shared library.
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: 
/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2    Rcpp_1.0.5
_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to