我使用最新的Rcpp
,R
,R-Shiny-Pro
和Ubuntu
获得了一些奇怪的行为。在R-Studio Server
我可以运行shiny::runApp()
并看到应用程序正常运行。但是,当我直接访问网站时,我会在Chrome的Javascript
控制台中看到此内容:
g++: error trying to exec 'cc1plus': execvp: No such file or directory
make: *** [file314215611f5d.o] Error 1
WARNING: The tools required to build C++ code for R were not found.
Please install GNU development tools including a C++ compiler.
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
我尝试使用Rcpp
重新安装apt-get install r-cran-rcpp
,并且可能在尝试之前错误地尝试了sudo apt-get install --reinstall g++-4.6
。除此之外,它只是:
follow instructions on http://cran.r-project.org/bin/linux/ubuntu/README.html
follow instructions on http://www.rstudio.com/products/shiny/download-commercial/
follow instructions on http://www.rstudio.com/products/rstudio/download-server/
sudo su - -c "R -e \"install.packages('Rcpp', repos='http://cran.cnr.berkeley.edu/')\""
除非轻松修复,否则我将尝试在不同的服务器上进行尝试,也许可以制作一个我可以分享的样本Shiny App。这在我以前的服务器上工作正常,这不是最新的Ubuntu
或专业版的R-Shiny
。非常感谢您提供的任何帮助。我是否使用cppFunction
。
增加:
我创建了一个最小的示例,它可以在不同的服务器上使用Shiny的免费版本,但不能与其他服务器一起使用除了Shiny版本之外具有相同的精确设置。这是ui.R:
library(shiny)
shinyUI(fluidPage(
titlePanel("Rcpp Check with Fibonacci"),
sidebarLayout(
sidebarPanel(
numericInput("inputnumber", "Input Number:", 10,
min = 1, max = 100)
),
mainPanel(
textOutput("text1")
)
)
))
服务器.R:
library(shiny);library(Rcpp)
cppFunction(
'int fibonacci(const int x) {
if (x == 0) return(0);
if (x == 1) return(1);
return (fibonacci(x - 1)) + fibonacci(x - 2);
}')
shinyServer(function(input, output) {
output$text1 <- renderText({as.character(fibonacci(input$inputnumber))
})
})
增加: 对于那些跟随我的人,我能够在R Studio Server中创建一个项目,以获得一个包含Rcpp的包.cpp文件:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int fibonacci(const int x) {
if (x == 0) return(0);
if (x == 1) return(1);
return (fibonacci(x - 1)) + fibonacci(x - 2);
}
我首先遇到的问题是通过确保按照here所述运行compileAttributes()
来解决的。这适用于两台服务器。