0

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.

ideamotor
  • 856
  • 1
  • 7
  • 23
  • 3
    Have you tried a `sudo apt-get install build-essential` on the web server? – hrbrmstr Jun 18 '14 at 03:28
  • 1
    And also `sudo apt-get install r-base-dev` to get the most common packages used for R builds. – Dirk Eddelbuettel Jun 18 '14 at 13:24
  • installing `build-essential` did not install anything and `r-base-dev` was installed prior to installing `Rcpp`. BTW, thanks for this amazing package Dirk - I have my copy of 'Seamless' right in front of me. – ideamotor Jun 18 '14 at 15:22
  • 1
    I still don't understand the error, but then my shiny apps use Rcpp code wrapped up in (sometimes local) packages which the shiny apps load. Do you really need compile within shiny? [ And thanks for the kind words about Rcpp. ] – Dirk Eddelbuettel Jun 18 '14 at 16:35
  • Right now the functions that really need to be in Rcpp for speed are static, so I'll take this that way, thanks. Found this thread http://stackoverflow.com/questions/14288254/moving-from-sourcecpp-to-a-package-w-rcpp. Since it works in RStudio Server and worked with the free version of Shiny I may take this up with their support. – ideamotor Jun 18 '14 at 18:40
  • Good you have it solved. Had you used a package as I suggested you'd have avoided that issue right from the start. – Dirk Eddelbuettel Jun 19 '14 at 22:24
  • any resolution to this? im having the same issue – Alex Gordon Apr 09 '15 at 01:24
  • Have you tried installing / upgrading Rtools `http://cran.r-project.org/bin/windows/Rtools/`? – Steve Pitchers Jul 10 '15 at 17:01
  • this has been resolved for me for a long time (I can create Rcpp functions on the fly) – ideamotor Jul 16 '15 at 20:53

0 Answers0