2
votes

I have installed Rcpp in the R console with this command that until now ussually works for installing packages to run on jupyter notebooks:

install.packages('Rcpp', '/home/user/anaconda3/lib/R/library/')

Then in the console I do:

library(Rcpp)
evalCpp("2+2")

and it works, but when I do the same on Jupyter notebooks it does not work, giving me this error message:

/home/tyatabe/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I/home/tyatabe/anaconda3/lib/R/include -DNDEBUG -I'/home/tyatabe/anaconda3/lib/R/library/SimInf/include' -I"/home/tyatabe/anaconda3/lib/R/library/Rcpp/include" -I"/tmp/RtmpC4usUT/sourceCpp-x86_64-conda_cos6-linux-gnu-0.12.15" -D_FORTIFY_SOURCE=2 -O2 -I/home/tyatabe/anaconda3/include -fpic -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -flto -ffat-lto-objects -Wno-unused-local-typedefs -Wno-ignored-attributes -Wno-deprecated-declarations -c file345f2e80a7c7.cpp -o file345f2e80a7c7.o /home/tyatabe/anaconda3/lib/R/etc/Makeconf:167: recipe for target 'file345f2e80a7c7.o' failed Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, : Error 1 occurred building shared library. Traceback:

  1. evalCpp("2+2")
  2. cppFunction(code, depends = depends, plugins = plugins, includes = includes, . env = env, rebuild = rebuild, cacheDir = cacheDir, showOutput = showOutput, . verbose = verbose)
  3. sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, . showOutput = showOutput, verbose = verbose)
  4. stop("Error ", status, " 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'm running on a 64 bit machine with Ubuntu 16.04.

Any ideas on how can I make Rcpp work on jupyter?

Thanks,

Tada

2

2 Answers

1
votes

As @DirkEddelbuettel mentioned... Anaconda isn't ideal on Ubuntu...

If you really want to have this setup, there was a recent entry to the Rcpp FAQ regarding compilers and Anaconda... In particular, we have:

In a comment to issue ticket#770 it is stated that running

sh conda install gxx_linux-64

helps within this enivronment as it installs the corresponding x86_64-conda_cos6-linux-gnu-c++ compiler.

1
votes

I generally recommend not to mix Ubuntu (where everything works as is) and Anaconda (which sometimes gets in the way).

And I have use Jupyter notebooks just fine on my box too.