4
OS: Ubuntu 14.04
g++: g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
R version: 3.2.0 (2015-04-16) -- "Full of Ingredients"
Rcpp: 0.11.6

Today I apt-get dist-upgrade my system, and the g++ was also been upgraded. Then when I am trying to use "Rcpp" package in R, the code is the simplest test code >>evalCpp("1+1") . An error as follows occurred:

Error in frameTypes(env) : not a proper evaluation environment
Calls: ::: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Error in sourceCpp(code = code, env = env, rebuild = rebuild,showOutput = showOutput,  : 
Error 1 occurred building shared library.

WARNING: The tools required to build C++ code for R were not found.

Please install GNU development tools including a C++ compiler.

I have did google for it. The following links are all about Mac OSX:

Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)

g++ errors when trying to compile c++11 with Rcpp

From the answers and comments, I can not tell what is the real problem. Appreciate your help!

UPDATE: I finally solved this problem by reinstalling all the R related deb packages. And one thing we should keep in mind is that I also did what @Dirk suggested first apt-get build-dep r-base-dev. I can not confirm which one is the key step.

Community
  • 1
  • 1
lovelyzlf
  • 107
  • 1
  • 11
  • Assuming this isn't solved yet, give me a hint: what command triggers the error message that you report? Also, the versions that you report don't agree with what I see. Can you run `cat /etc/issue.net` and report the results? – Brent Bradburn May 15 '15 at 15:39
  • @nobar It is just the simplest Rcpp test code :evalCpp("1+1") – lovelyzlf May 15 '15 at 15:56
  • `evalCpp("1+1")` works fine for me on Ubuntu 14.04.1. But like I said, your various package versions don't seem to make sense. I think there is a bit of ambiguity about what you are running after doing the dist-upgrade. Maybe you should do a [full-upgrade](http://askubuntu.com/a/81594/11522) to get your package versions straightened out. – Brent Bradburn May 15 '15 at 16:06
  • @nobar I have seen your comment under http://askubuntu.com/a/81594/11522 . I don't see `full-upgrade` option either. Have you figure out the reason? – lovelyzlf May 16 '15 at 04:26
  • Nope. It isn't in my man-pages and the command doesn't support it. I recommended it to you based only on that post -- which turned out to be incorrect. – Brent Bradburn May 16 '15 at 04:32

2 Answers2

3

You need

 sudo apt-get build-dep r-base

to install the all the build dependencies for R itself.

But we even built an explicitly helper package r-base-dev so in most cases (and in your use case of Rcpp) you just need

 sudo apt-get install r-base-dev
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Really thank you for your help, I shall test your solution later and post the result. Since I am not accessible to my computer. But what I am curious is why this problem happen? Is there any permanent solution? If next time I upgrade g++ , will this problem happen again? – lovelyzlf May 15 '15 at 16:02
  • Yes, it is permanent. No, you do not need to do it again. Also look at the [Rcpp FAQ](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-FAQ.pdf) and other documentation. – Dirk Eddelbuettel May 15 '15 at 16:04
  • I have followed your solution and still got the same error. And the final solution is that I reinstalled all the `r-base-core` related packages. And off course the `sudo apt-get build-dep r-base` does pull some extra packages first before reinstallation. I am not sure which procedure is the key ingredient, or both. Anyway I thank you for your help! – lovelyzlf May 16 '15 at 03:15
1

There is something wrong/missing in your system configuration. First of all, I doubt that you are really running Ubuntu 14.04 (after the dist-upgrade) because the the other versions that you listed wouldn't be available (unless you have pulled them in from a non-default repository). You might also consider running a full-upgrade to try to straighten out your configuration.

You might gain some insights by running with showOutput=1...

library(Rcpp)
evalCpp("1+1",showOutput=1,rebuild=1)

...but actually, it looks like the problem is related specifically to a parameter called env (Error in frameTypes(env) : not a proper evaluation environment) which is likely evaluated prior-to attempting to compile.

For what it is worth, I was able to run this without r-base-dev installed, but maybe installing r-base-dev will pull in the correct, and updated, versions of what you need. I would be inclined to just reinstall all R-related packages.

Community
  • 1
  • 1
Brent Bradburn
  • 51,587
  • 17
  • 154
  • 173
  • I always use `apt-get dist-upgrade` to update my system. And I have used an non-default repository for `CRAN`: http://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu/trusty/ – lovelyzlf May 16 '15 at 02:23
  • @lovelyzlf: I actually don't know too much about `apt-get` upgrade options because I never do it that way. What I see, though, is that *none* of the versions that you indicated are available from the 14.04.1 default repositories ([including g++](http://packages.ubuntu.com/trusty/g++-4.8)) -- and that was a red flag. Not that it matters -- I suspect you just need a clean install of R and its packages (but preferably not so bleeding edge). – Brent Bradburn May 16 '15 at 02:48
  • The final solution is reinstallation! See the comments I give for @Dirk's answer. Thanks anyway! – lovelyzlf May 16 '15 at 03:17
  • @lovelyzlf: Great! Then my suggestion worked: "I would be inclined to just reinstall all R-related packages". – Brent Bradburn May 16 '15 at 03:48
  • Yes, you got the up vote! And I got the g++ info from `g++ --version` and it is a little bit different from what you see form the `Synaptic Package Manager`. – lovelyzlf May 16 '15 at 04:22