Discussion:
[Rcpp-devel] Fwd: Installing Rcpp and working a compilation with C++
Benjamin S. Levy
2018-11-01 01:42:09 UTC
Permalink
In regard to my prior enquiry, I restored the ‘trusty’ to ‘bionic’ items in the sources.list; thank you for that tip. Also, the [B artifact in my prior post was just from a carriage return between systems. I have the location of the Rccp/include and .//libs per Listing 2.1, and am evidently still missing connection. I spent some time with a Linux expert today, and he could not find the issue. If there is a more recent link (I think it was cited), for help, I should be obliged.

With all due respect and much thanks, I am

Benjamin Levy, Ph.D.
Subject: Installing Rcpp and working a compilation with C++
Date: October 30, 2018 at 2:45:17 PM EDT
Hello. Thanks for granting me privileges to ask a new-person question. With all respect and hopes for some help. BSL
I’m working with Dirk Eddelbuettel’s book and trying to conduct the first manual compilation with Rcpp (Listing 2.1). I’m hitting a snag. Here are the circumstances. Perhaps the problem is my location of R in /usr/bin/ and the Rccp packages (and friends) in usr/local/lib/R/site-library/Rcpp? I put the error message at the bottom, after the system-level detail.
VMWare Ubuntu 18.04
Software
R (command line) 3.5.1 (it is functional); R is installed at /usr/bin/
packages installed from CRAN: Rcpp, Rcpp11, RcppArmadillo, SPREDA, RUnit, inline, rbenchmark, RInside
Installation location: /home/myDir/R/x86_64-pc-linux-gnu-library/3.5/
Visual Studio 1.28.2 with c++ and gcc (it is functional)
Installed texlive-latex-extra at command line
Edited all instances in source.list from ‘bionics’ to ‘trusty’ per recommendation from https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list <https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list>
Located in /etc/apt/
deb-src http://archive.ubuntu.com/ubuntu <http://archive.ubuntu.com/ubuntu> trusty main restricted #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ <http://gb.archive.ubuntu.com/ubuntu/> trusty restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ <http://gb.archive.ubuntu.com/ubuntu/> trusty-updates restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ <http://gb.archive.ubuntu.com/ubuntu/> trusty-backports main restricted universe multiverse #Added by software-properties
deb-src http://security.ubuntu.com/ubuntu <http://security.ubuntu.com/ubuntu> trusty-security restricted main universe multiverse #Added by software-properties
Fibonacci code
Located in /home/myDir/Documents/seamlessR/R examples/fibonacci.cpp
Code snippet
int fibonacci( const int x){
if(x == 0) return(0);
if(x == 1) return(1);
return(fibonacci(x-1) + fibonacci(x-2));
}
extern “C” SEXP fibWrapper(SEXP xs){
int x = Rcpp::as<int>(as);
int fib = fibonacci(x);
return( Rcpp:wrap(fib));
}
Issued first command at Ubuntu terminal prompt from Listing 2.1
sh> PKG_CXXFLAGS="-I/usr/local/lib/R/site-library/Rcpp/include" \ PKG_LIBS="-L/home/myDir/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/libs -lRcpp" \ R CMD SHLIB fibonacci.cpp
Reply: bash: PKG_CXXFLAGS=-I/usr/local/lib/R/site-library[B/Rcpp/include: No such file or directory
Dirk Eddelbuettel
2018-11-01 02:18:03 UTC
Permalink
On 31 October 2018 at 21:42, Benjamin S. Levy wrote:
| In regard to my prior enquiry, I restored the ‘trusty’ to ‘bionic’ items in the sources.list; thank you for that tip. Also, the [B artifact in my prior post was just from a carriage return between systems. I have the location of the Rccp/include and .//libs per Listing 2.1, and am evidently still missing connection. I spent some time with a Linux expert today, and he could not find the issue. If there is a more recent link (I think it was cited), for help, I should be obliged.

As I mentioned to you yesterday:

- read the Rcpp Introduction vignette
- if you can, also read the Rcpp Attributes vignette

As a litmus test, do one call to Rcpp::evalCpp() such as this:

R> Rcpp::evalCpp("2 + 2")
[1] 4
R>

After a second or two, 4 should appear as the answer. It will have come from
a new subroutine R and Rcpp just compiled for you.

So if it does, your toolchain works. Linux is in my opinion also the easiest
system to get this working as you generally have a working compiler
already. Both windows and macOS need extra work to make R use a matching
compiler.

But if it doesn't, consult the Rcpp FAQ vignette and other R documentation
resources. How to make compilation work with R is needed for Rcpp, but _not_
specific to Rcpp -- it is the same for _any_ R package involving compilation.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Ralf Stubner
2018-11-01 10:10:15 UTC
Permalink
PKG_CXXFLAGS="-I/usr/local/lib/R/site-library/Rcpp/include" \
PKG_LIBS="-L/home/myDir/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/libs
This looks fishy. For PKG_CXXFLAGS you say that Rcpp is installed in
/usr/local/lib/R/site-library/Rcpp/. For PKG_LIBS you use
/home/myDir/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/. Where is it
actually installed?

Greetings
Ralf
--
Ralf Stubner
Senior Software Engineer / Trainer

daqana GmbH
Dortustraße 48
14467 Potsdam

T: +49 331 23 61 93 11
F: +49 331 23 61 93 90
M: +49 162 20 91 196
Mail: ***@daqana.com

Sitz: Potsdam
Register: AG Potsdam HRB 27966
Ust.-IdNr.: DE300072622
GeschÀftsfÌhrer: Dr.-Ing. Stefan Knirsch, Prof. Dr. Dr. Karl-Kuno Kunze
Benjamin S. Levy
2018-11-01 11:31:49 UTC
Permalink
In order of the advice from others who replied to my first question:

1. Inaki Ucar. Thank you. Being new to Ubuntu and Linux, I was unaware of the dire implications of changes in the sources.list file. All instances of ‘trusty’ have been changed back to ‘bionics’. It was included as a possible reason for my inability to compile and link R and C++; so, from a new-person perspective, it was useful.

2. Dirk Eddelbuettel. The ‘litmus’ test that you suggested worked. Thank you. Glad to know that it will be supported on Windows10 (and MacOS, too, I assume). Now, also, I know about the r-sig-debian list, which is where I will now be able to direct relevant questions.

3. Ralf Stubner. Your suggestion gets to the reason why I asked. I will explore the suggestion with care.

Again, with all due respect and thanks.

BSL
Subject: Re: [Rcpp-devel] Fwd: Installing Rcpp and working a compilation with C++
Date: November 1, 2018 at 6:10:15 AM EDT
PKG_CXXFLAGS="-I/usr/local/lib/R/site-library/Rcpp/include" \
PKG_LIBS="-L/home/myDir/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/libs
This looks fishy. For PKG_CXXFLAGS you say that Rcpp is installed in
/usr/local/lib/R/site-library/Rcpp/. For PKG_LIBS you use
/home/myDir/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/. Where is it
actually installed?
Greetings
Ralf
--
Ralf Stubner
Senior Software Engineer / Trainer
daqana GmbH
Dortustraße 48
14467 Potsdam
T: +49 331 23 61 93 11
F: +49 331 23 61 93 90
M: +49 162 20 91 196
Sitz: Potsdam
Register: AG Potsdam HRB 27966
Ust.-IdNr.: DE300072622
GeschÀftsfÌhrer: Dr.-Ing. Stefan Knirsch, Prof. Dr. Dr. Karl-Kuno Kunze
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Loading...