[英]Using Rcpp headers in C++
I'm an R programmer trying to learn C++ because I've seen the vast improvements you can make to code using C++ code within R. I'm trying to play around with the Rcpp library, and I've gotten examples to work in R. However, I'd like to write some C++ code in my C++ editor and use some of the classes from Rcpp (just to get a better understanding of how to use the package). 我是一位R程序员,试图学习C ++,因为我已经看到您可以在R中使用C ++代码进行代码的巨大改进。我正在尝试使用Rcpp库,并且已经有了一些可以使用的示例。 R。但是,我想在C ++编辑器中编写一些C ++代码,并使用Rcpp中的一些类(只是为了更好地了解如何使用该程序包)。 I tried to compile the following code in my C++ editor (CodeBlocks):
我尝试在C ++编辑器(CodeBlocks)中编译以下代码:
include </path_to_R/R/win-library/2.15/Rcpp/include/Rcpp.h>
but then it fails because it can't find from the first few lines of : 但随后失败,因为它无法从以下的前几行中找到:
%...
#ifndef Rcpp_hpp
#define Rcpp_hpp
/* it is important that this comes first */
#include <RcppCommon.h>
...
Is there a better way to include all the Rcpp code? 有没有更好的方法来包含所有Rcpp代码? Do I need to go through the Rcpp.h file and replace all the file names with their paths?
我是否需要浏览Rcpp.h文件并将所有文件名替换为其路径?
I realize this is a newby question, and I'm sorry... I'm sure the answers out in the documentation somewhere, but I don't know how to even look for it. 我意识到这是一个新问题,很抱歉...我确定文档中某个地方的答案,但我什至不知道该如何寻找。 Thanks for the help!
谢谢您的帮助!
You could, and maybe should, look at the Rinside package which embeds R into C++ -- so C++ is the main()
here and the Makefile snippets will give you an idea. 您可以(也许应该)查看将R嵌入到C ++中的Rinside软件包-因此,C ++是此处的
main()
,Makefile代码段将为您提供一个想法。
People have used Rinside with different IDEs and there are contributed files for use with Eclipse etc pp. Try those, and if you need more help then try the rcpp-devel list as the author of those contributed files may not read posts here. 人们在不同的IDE上使用了Rinside,并且有供Eclipse等pp使用的贡献文件。尝试使用那些,如果需要更多帮助,请尝试rcpp-devel列表,因为这些贡献文件的作者可能不会在此处阅读文章。
Although, of course, Code::Blocks is not eclipse, you might find this guide informative at to what it takes to get an IDE to play nicely with R and Rcpp. 当然,虽然Code :: Blocks并不是日食,但您可能会发现本指南提供了有关使IDE与R和Rcpp完美配合所需要的信息。
If you are able and willing, it would be useful if you documented similar steps as to how you got Code::Blocks to work alongside R / Rcpp. 如果您有能力并且愿意的话,如果您记录了如何使Code :: Blocks与R / Rcpp一起工作的类似步骤,将很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.