[Rcpp-devel] Regular Expressions
On Sat, Mar 2, 2013 at 7:05 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
On 2 March 2013 at 18:47, Gabor Grothendieck wrote: | On Sat, Mar 2, 2013 at 10:17 AM, Dirk Eddelbuettel <edd at debian.org> wrote: | > | > On 1 March 2013 at 23:03, Gabor Grothendieck wrote: | > | On Fri, Mar 1, 2013 at 9:50 PM, Dirk Eddelbuettel <edd at debian.org> wrote: | > | > | > | > On 1 March 2013 at 21:24, Hadley Wickham wrote: | > | > | > | I searched BH for regex and found nothing so I don't think BH includes | > | > | > | Boost.Regex. | > | > | > | > | > | > Could you register an issue ticket at the r-forge page for BH, please? There | > | > | > are other things missing too, of course, as we started pretty with the needs | > | > | > of "just" bigmemory and RcppBDT. | > | > | | > | > | But Boost.Regex isn't header only? | > | > | > | > Yup. Found that out the hard way when I wrote it up as a piece for the Rcpp | > | > Gallery. You do need to link. | > | > | > | > Piece now up at http://gallery.rcpp.org/articles/boost-regular-expressions/ | > | > | > | | > | I have downloaded boost such that I have this file: | > | | > | C:\MinGW\lib\libboost_regex.a | > | | > | How do I tell Rcpp to use it? | > | > Follow eg the Rcpp Gallery story and use | > | > Sys.setenv("PKG_LIBS"="C:\MinGW\lib\libboost_regex.a") | > | > as static library can be given "as is". Else try | > | > Sys.setenv("PKG_LIBS"="-LC:\MinGW\lib\ -lboost_regex") | > | > which is the standard form. That should work with the example I posted. | > | > If everthing else, try the documentation for Rcpp (Rcpp-package vignette in | > particular) or Boost. | > | | Thanks. I doubled each backslash but unfortunately neither work. | | I am able to build the original credit_card_example from the boost | site independently of Rcpp, i.e. this builds and I can run the result: | | rem this works | C:\MinGW\set_distor_paths.bat | g++ credit_card_example.cpp -o credit_card_example.exe -lboost_regex | | and can also build C++ scripts not using boost; however, | | all of the following give: | credit.cpp:6:27: fatal error: boost/regex.hpp: No such file or directory | | library(Rcpp) | Sys.setenv("PKG_LIBS"="C:\\MinGW\\lib\\libboost_regex.a") | sourceCpp("credit.cpp", verbose = TRUE) | | library(Rcpp) | Sys.setenv("PKG_LIBS"="-LC:\\MinGW\\lib\\ -lboost_regex") | sourceCpp("credit.cpp", verbose = TRUE) | | library(Rcpp) | Sys.setenv("PKG_LIBS"="-lboost_regex") | sourceCpp("credit.cpp", verbose = TRUE) | | I also tried with Cygwin. I have this file among others: | C:\cygwin\lib\libboost_regex-mt.dll.a | | and tried these but they give the same result: | | library(Rcpp) | Sys.setenv("PKG_LIBS"="C:\\cygwin\\lib\\libboost_regex-mt.dll.a") | sourceCpp("credit.cpp", verbose = TRUE) | | library(Rcpp) | Sys.setenv("PKG_LIBS"="-LC:\\cygwin\\lib\\ -lboost_regex") | sourceCpp("credit.cpp", verbose = TRUE) | | Changing backslash to forward slash does not change anything. | | Everything was done with the svn version of Rcpp: | | > packageVersion("Rcpp") | [1] '0.10.2.5' Sorry that this is so frustrating, but this (IMNSHO) all just Windows... I would try two things: a) forward slashes (no escaping needed) b) use verbose=TRUE so that you see the R CMD ... invocation. Your initial boost test was key. We know you have a working boost library; we know Rcpp can create working code, now we just need to tie'em together.
I had tried both these. It does not seem to be picking up the PKG_LIBS. There is no -l... or -L... on the g++ cmd line. Its also not clear precisely which boost distribution to use. I had tried http://nuwen.net/mingw.html (version 8.0) and also tried the boost library from Cygwin. If I use the MinGW from nuewn and run this from the Windows cnd line I get no errors or warnings (note that ^ must be the last character on the line to escape the newline): C:\MinGW\set_distro_paths.bat g++ -DNDEBUG ^ -L %userprofile%/Documents/R/win-library/2.15/Rcpp/lib/x64/libRcpp.a ^ -lboost_regex ^ -I"C:/PROGRA~1/R/R-2.15/include" ^ -I%userprofile%/Documents/R/win-library/2.15/Rcpp/include ^ -O2 -Wall -mtune=core2 -c credit.cpp -o credit.o If tyhat is ok then what would the next step be? -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com