Mac OS X上的Rcpp + Eclipse [英] Rcpp+Eclipse on Mac OS X

查看:208
本文介绍了Mac OS X上的Rcpp + Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开始使用Rccp,并决定使用Eclipse作为开发环境,因为我已经使用了StatEt for R。我很难获得一个简单的程序来编译和运行,并希望有一些帮助!



简单来说,我试图按照博客上的说明: http://blog.fellstat.com/?p=170 完全用于设置Rcpp,RInside和Eclipse以及示例程序。我在Mountain Lion上运行,并使用XCode中的命令行选项安装了g ++。我认为我忠实地遵循了博客中的所有步骤,但无法让程序编译。我认为问题是包含头文件的方式,如下面输出的代码段所示。据我所知, / usr / include / c ++ / 4.2.1 / cstring 的第52行是< string的include语句。 h> ,编译器包括 Rccp / include / string.h 而不是 string.h 来自 std ,它在包含路径之前找到。



我是C ++中的新手,所以我真的很感激一些关于如何继续的指针。



-Krishna

  16:22:38 ****增量配置调试项目MyTestRCppPackage **** 
信息:内部构建器用于构建
g ++ -DINSIDE -I / Library / Frameworks / R.framework / Versions / 2.15 / Resources / include - I / Library / Frameworks / R.framework / Versions / 2.15 / Resources / library / Rcpp / include -I / Library / Frameworks / R.framework / Versions / 2.15 / Resources / library / Rcpp / include / Rcpp -I / Library /框架/框架/版本/ 2.15 / Resources / library / RInside / include -O0 -g3 -Wall -c -fmessage-length = 0 -arch x86_64 -v -o src / main.o ../src/main。 cpp
使用内置的规格。
目标:i686-apple-darwin11
配置为:/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix = /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir = / share / man --enable-languages = c,objc,c ++,obj-c ++ --program-prefix = llvm- - -program-transform-name = / ^ [cg] [^ .-] * $ / s / $ / - 4.2 / --with-slibdir = / usr / lib --build = i686-apple-darwin11 --enable- llvm = / private / var / tmp / llvmgcc42 / llvmgcc42-2336.11〜182 / dst-llvmCore / Developer / usr / local --program-prefix = i686-apple-darwin11- --host = x86_64-apple-darwin11 - X-454545454545 X-454545 X-454545 X-454545 X-454545 X-454545 X-454545 X-4545 X-454545新新新新新新新新新旗新新旗新新旗新新旗新旗新新旗新旗新旗新旗新5658)(LLVM build 2336.11.00)
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1plus -quiet -v -I / Library /Frameworks/R.framework/Versions/2.15/Resources/include -I / Library / Frameworks / R.framework / Versions / 2.15 / Resources / library / Rcpp / include -I / Library / Frameworks /R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I / Library / Frameworks / R.framework / Versions / 2.15 / Resources / library / RInside / include -imultilib x86_64 -iprefix / usr / llvm- gcc-4.2 / bin /../ lib / gcc / i686-apple-darwin11 / 4.2.1 / -dD -D__DYNAMIC__ -DINSIDE ../src/main.cpp -fPIC -quiet -dumpbase main.cpp -mmacosx-version -min = 10.8.3 -m64 -mtune = core2 -auxbase-strip src / main.o -g3 -O0 -Wall -version -fmessage-length = 0 -D__private_extern __ = extern -o / var / folders / hc / vqp48jt56_v332kc3dqyf5780000gn / T // ccqdmOKI.s
忽略不存在的目录/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../ .. /../i686-apple-darwin11/include
忽略不存在的目录/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64
忽略不存在的目录/应用程序/ Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include
#include...搜索从这里开始:
#include< ...>搜索从这里开始:
/Library/Frameworks/R.framework/Versions/2.15/Resources/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include
/usr/include/c++/4.2.1
/ usr / include / c ++ / 4.2.1 / backward
/ usr / local / include
/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686- apple-darwin11 / 4.2.1 / include
/ usr / include
/系统/库/框架(框架目录)
/库/框架(框架目录)
搜索结束名单。
GNU C ++版本4.2.1(基于Apple Inc. build 5658)(LLVM build 2336.11.00)(i686-apple-darwin11)
由GNU C版本4.2.1编译(基于Apple Inc 。build 5658)(LLVM build 2336.11.00)。
GGC启发式:--param ggc-min-expand = 150 --param ggc-min-heapsize = 65536
编译器可执行校验和:b37fef824b01c0a99fb2679acf3b04f1
在/ usr / include / c ++中包含的文件/4.2.1/cstring:52,
来自/usr/include/c++/4.2.1/bits/stl_algobase.h:66,
来自/usr/include/c++/4.2.1/memory来自/usr/include/c++/4.2.1/tr1/hashtable:56的
,来自/usr/include/c++/4.2.1/tr1/unordered_map:37的

从/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:158,
/来自/Library/Frameworks/R.framework/Versions/2.15 /Resources/library/Rcpp/include/RcppCommon.h:26,
来自/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp.h:27,
从../src/main.cpp:8:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52:错误:'internal'尚未声明
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52:错误:typedef名称可能不是nested-name-specifier
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52:error:expected';'before'&'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:65:error:expected`)'before'charsxp'
/ Library /新新新新新旗新新新新旗新新旗新新旗新新旗旗新新旗新新新旗新新旗旗新新旗新新新新旗新新旗旗新新旗旗新新旗新新旗200新新新新旗新新新新旗新新旗名: /Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75:error:expected'&'token
/ Library / Frameworks / R之前的未标识的id。新评新新新旗新新新新旗新新旗旗目新旗新新旗200新新新新旗新新旗200新新新新旗新新旗200新新新新旗新新旗200新新新新新旗新新旗新新旗200新新新新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗200 .fra作业/版本/ 2.15 /资源/库/ Rcpp / include / Rcpp / string.h:75:错误:'Rcpp :: String :: String()'不能重载
/Library/Frameworks/R.framework /Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:55:error:with'Rcpp :: String :: String()'
/Library/Frameworks/R.framework/Versions/ 2.15 / Resources / library / Rcpp / include / Rcpp / string.h:85:error:'Rcpp :: String :: String(int)'不能重载
/Library/Frameworks/R.framework/Versions/ 2.15 / Resources / library / Rcpp / include / Rcpp / string.h:70:error:with'Rcpp :: String :: String(int)'
/Library/Frameworks/R.framework/Versions/2.15/资源/库/ Rcpp / include / Rcpp / string.h:88:error:expected`)'before'x'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include X-454545454545 X-45454545 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X-方案

总而言之,我遇到的问题是在 Rcpp 中包含文件ames名称与 std 中的名称相冲突。特别是, string.h Rcpp 被包含在 string.h std 是正确的选择,据我所知,这是因为通过 -I 指令在默认路径之前被搜索。



我尝试了许多不同的替代方案来解决这个问题,安装XCode和相关的命令行工具,以及使用macports安装另一个g ++编译器。这些都没有解决问题。新新旗新新旗新新旗新新旗新新旗旗新新旗新新旗新旗旗新新旗旗新200 200 200 200 200 200 200:45 200 200新新旗200 200 200 200新新新新旗新新旗200 Chan旗新新新旗200 Chan旗新新新旗200 Chanol旗新1992新新旗200我从 gcc include order broken?得到这个提示。这是因为这些目录在默认路径之后被搜索。这样排除了(至少到目前为止) string.h std 来自 Rcpp 的string.h 冲突。 X-4545454545X-45454545 X- 2004545 X- 20045 X-454545 X- 20045 X-454545 X- 20045 X- 20045 X- 20045 X-454545 X- /blog.fellstat.com/?p=170 工作,我必须在 PKG_CPPFLAGS -idirafter 路径$ c $在文件 Makevars



感谢大家的建议。


I am trying to get started using Rccp and decided to use Eclipse as a development environment since I already use StatEt for R. I am having trouble getting even a simple program to compile and run though, and would appreciate some help!

Briefly I tried to follow the instructions on the blog: http://blog.fellstat.com/?p=170 exactly for setting up Rcpp, RInside and Eclipse, and for the example program. I am running on Mountain Lion, and installed g++ using the command line options in XCode. I think I've faithfully followed all the steps in the blog, but cannot get the program to compile. I think the problem is in the way the header files are included, as indicated from the snippet of the output below. As far as I can tell, line 52 of /usr/include/c++/4.2.1/cstring is an include statement for <string.h> and the compiler includes Rccp/include/string.h instead of the string.h from std that is found earlier on the include path.

I am a novice in C++ so I'd really appreciate some pointers on how to proceed.

-Krishna

16:22:38 **** Incremental Build of configuration Debug for project MyTestRCppPackage ****
Info: Internal Builder is used for build
g++ -DINSIDE -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -O0 -g3 -Wall -c -fmessage-length=0 -arch x86_64 -v -o src/main.o ../src/main.cpp 
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
 /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1plus -quiet -v -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -imultilib x86_64 -iprefix /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/ -dD -D__DYNAMIC__ -DINSIDE ../src/main.cpp -fPIC -quiet -dumpbase main.cpp -mmacosx-version-min=10.8.3 -m64 -mtune=core2 -auxbase-strip src/main.o -g3 -O0 -Wall -version -fmessage-length=0 -D__private_extern__=extern -o /var/folders/hc/vqp48jt56_v332kc3dqyf5780000gn/T//ccqdmOKI.s
ignoring nonexistent directory "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
#include "..." search starts here:
#include <...> search starts here:
 /Library/Frameworks/R.framework/Versions/2.15/Resources/include
 /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include
 /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp
 /Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include
 /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include
 /usr/include/c++/4.2.1
 /usr/include/c++/4.2.1/backward
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
GNU C++ version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) (i686-apple-darwin11)
    compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=65536
Compiler executable checksum: b37fef824b01c0a99fb2679acf3b04f1
In file included from /usr/include/c++/4.2.1/cstring:52,
                 from /usr/include/c++/4.2.1/bits/stl_algobase.h:66,
                 from /usr/include/c++/4.2.1/memory:53,
                 from /usr/include/c++/4.2.1/tr1/hashtable:56,
                 from /usr/include/c++/4.2.1/tr1/unordered_map:37,
                 from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:158,
                 from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/RcppCommon.h:26,
                 from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp.h:27,
                 from ../src/main.cpp:8:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: 'internal' has not been declared
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: typedef name may not be a nested-name-specifier
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: expected ';' before '<' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:65: error: expected `)' before 'charsxp'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected unqualified-id before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: 'Rcpp::String::String()' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:55: error: with 'Rcpp::String::String()'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:85: error: 'Rcpp::String::String(int)' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: with 'Rcpp::String::String(int)'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:88: error: expected `)' before 'x'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:89: error: expected `)' before 'x'

解决方案

To summarize, the issue I faced was that include files in Rcpp with the sames names as those in std were in conflict. In particular, string.h from Rcpp was being included at a point where string.h from std was the right choice, and, as far as I could tell, this was due to the fact that paths specified via the -I directive are searched prior to the default paths.

I tried many different alternatives to solve this, including removing and re-installing XCode and the associated Command Line tools, as well as installing another g++ compiler using macports. None of these resolved the issue. I then used the -idirafter directive instead of the -I directive for the search path for include files for Rcpp and R. I got this hint from gcc include order broken?. This worked since these directories are now searched after the default paths. This precludes (at least so far!) the possibility that string.h from std and string.h from Rcpp come into conflict.

To get step 5 of http://blog.fellstat.com/?p=170 to work I had to set the -idirafter paths in PKG_CPPFLAGS in the file Makevars.

Thanks to everyone for your suggestions.

这篇关于Mac OS X上的Rcpp + Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆