在Mac OS X上使用

时间:2014-04-03 15:12:53

标签: c++ r rcpp

我在OS X 10.9.2上安装了带有mac端口的R 3.0.3。我用sudo R CMD INSTALL安装了RInside~ / Downloads / RInside_0.2.11.tgz(类似于Rcpp_0.11.1.tar)。我正在尝试从http://dirk.eddelbuettel.com/code/rinside.html编译一个简单的RInside帮助世界代码。我正在尝试使用

g++ main.cpp -I/Users/robogos/Library/R/3.0/library/RInside/include/ -I/Users/robogos/Library/R/3.0/library/Rcpp/include/ -I/opt/local/Library/Frameworks/R.framework/Versions/3.0/Resources/include/

我得到一长串错误:

Undefined symbols for architecture x86_64:
  "_REprintf", referenced from:
      Rcpp::Rstreambuf<false>::xsputn(char const*, long) in main-4b77b4.o
      Rcpp::Rstreambuf<false>::overflow(int) in main-4b77b4.o
  "_R_BindingIsLocked", referenced from:
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
  "_R_FlushConsole", referenced from:
      Rcpp::Rstreambuf<false>::sync() in main-4b77b4.o
      Rcpp::Rstreambuf<true>::sync() in main-4b77b4.o
  "_R_NilValue", referenced from:
      Rcpp::wrap(char const*) in main-4b77b4.o
  "_R_UnboundValue", referenced from:
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
  "_Rf_defineVar", referenced from:
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
  "_Rf_findVarInFrame", referenced from:
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
  "_Rf_install", referenced from:
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
      Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
  "_Rf_mkString", referenced from:
      Rcpp::wrap(char const*) in main-4b77b4.o
  "_Rprintf", referenced from:
      Rcpp::Rstreambuf<true>::xsputn(char const*, long) in main-4b77b4.o
      Rcpp::Rstreambuf<true>::overflow(int) in main-4b77b4.o
  "RInside::parseEvalQ(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in main-4b77b4.o
  "RInside::RInside(int, char const* const*, bool, bool, bool)", referenced from:
      _main in main-4b77b4.o
  "RInside::~RInside()", referenced from:
      _main in main-4b77b4.o
  "RInside::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in main-4b77b4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经尝试过Dirk Eddelbuettel的建议,但现在我收到了:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
  Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
  Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
 in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
  Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
  Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
 in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
  Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
  Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
 in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
  Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
  Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
 in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 
make: Nothing to be done for `rinside_sample0.cpp'.

我见过像!unset DYLD_LIBRARY_PATH;这样的建议,但我不知道如何在我的情况下这样做。

1 个答案:

答案 0 :(得分:0)

使用模式是

  • cd进入examples/standard/目录

  • 运行make

  • 或运行make rinside_sample0(或任何其他名称),如果您只想构建一个。

您可以添加自己的文件,make nameofthefile将构建可执行文件。

简而言之,您不能像以前那样致电g++