I'm getting some odd behavior using the latest Rcpp
, R
, R-Shiny-Pro
, and Ubuntu
. In R-Studio Server
I can run shiny::runApp()
and see the application working properly. However, when I go directly to to Website I see this in Chrome's Javascript
Console:
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.
I've tried re-installing Rcpp
with apt-get install r-cran-rcpp
and perhaps wrongly tried sudo apt-get install --reinstall g++-4.6
prior to one attempt. Other than that it's just been:
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/')\""
Barring an easy fix, I'm going to try it on a different server and perhaps make a sample Shiny App I can share. This worked fine on my previous server which was not the latest Ubuntu
or the Professional version of R-Shiny
. Much appreciation for any help you may provide. FWIW I'm using cppFunction
.
ADDED:
I created a minimal example and it works on a different server with the free version of Shiny but not with this other server with the same exact setup other than the Shiny version. Here's the 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")
)
)
))
And the server.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))
})
})
ADDED: For those following along I was able to make a project in R Studio Server for a package with Rcpp sourcing this .cpp file:
#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);
}
The issue I first ran into was resolved by making sure I ran compileAttributes()
as described here. This works for both servers.