[Rcpp-devel] Seamless Rcpp gives errors with RcppArmadillo

John Swan johnswan at spamcop.net
Thu Jun 27 02:39:05 CEST 2013


Hi all,

Thanks for all the advice. I had a large number of rookie mistakes in there!

However, I still can't get anything to work. Details below:

I do have RcppArmadillo installed:
> installed.packages()
               Package          LibPath                                                          Version     Priority      Depends                                               
inline         "inline"         "/Users/johnswan/Library/R/3.0/library"                          "0.3.12"    NA            "R (>= 2.4.0), methods"                         
Rcpp           "Rcpp"           "/Users/johnswan/Library/R/3.0/library"                          "0.10.3"    NA            "R (>= 2.15.1)"                                 
RcppArmadillo  "RcppArmadillo"  "/Users/johnswan/Library/R/3.0/library"                          "0.3.900.0" NA            "R (>= 2.14.0), Rcpp (>= 0.10.2)"      


1) Attempt Inline using source:

somefile.R:
library(Rcpp)
library(inline)
library(RcppArmadillo)

rowSumsRA <- cxxfunction(signature(x = "numeric"), plugin="RcppArmadillo", body='return Rcpp::wrap(arma::sum(as<arma::mat>(x),0));')
colSumsRA <- cxxfunction(signature(x = "numeric"), plugin="RcppArmadillo", body='return Rcpp::wrap(arma::sum(as<arma::mat>(x),1));')


> source("./R/somefile.R")
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
ld: library not found for -lgfortran
collect2: ld returned 1 exit status
make: *** [file77e07e2ff1b6.so] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: #include <RcppArmadillo.h>
  4: #include <Rcpp.h>
  5: 
  6: 
  7: #ifndef BEGIN_RCPP
  8: #define BEGIN_RCPP
  9: #endif
 10: 
 11: #ifndef END_RCPP
 12: #define END_RCPP
 13: #endif
 14: 
 15: using namespace Rcpp;
 16: 
 17: 
 18: // user includes
 19: 
 20: 
 21: // declarations
 22: extern "C" {
 23: SEXP file77e07e2ff1b6( SEXP x) ;
 24: }
 25: 
 26: // definition
 27: 
 28: SEXP file77e07e2ff1b6( SEXP x ){
 29: BEGIN_RCPP
 30: return Rcpp::wrap(arma::sum(as<arma::mat>(x),0));
 31: END_RCPP
 32: }
 33: 
 34: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
ld: library not found for -lgfortran
collect2: ld returned 1 exit status
make: *** [file77e07e2ff1b6.so] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file77e07e2ff1b6.cpp 2> file77e07e2ff1b6.cpp.err.txt' had status 1 


2) Attempt using sourceCpp:
> sourceCpp("./R/Psi.cpp")
Error in sourceCpp("./R/Psi.cpp") : 
  Error 1 occurred building shared library.
ld: warning: directory 
WARNING: The tools required to build C++ code for R were not found.

Please install Command Line Tools for XCode (or equivalent).

not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
ld: library not found for -lgfortran
collect2: ld returned 1 exit status
make: *** [sourceCpp_84974.so] Error 1
> 

As mentioned before, I do have the Xcode command line tools installed:
John-MBPR:BDGraphSource johnswan$ which llvm-g++
/usr/bin/llvm-g++
John-MBPR:BDGraphSource johnswan$ llvm-g++ --version 
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 Is there any way I can get more verbose information, get at the environment variables or compiler options used by Rcpp or anything?


Thanks
John


More information about the Rcpp-devel mailing list