useR!2014 Rcpp11 tutorial

287 views
Skip to first unread message

KarenL

unread,
Jun 25, 2014, 1:03:43 PM6/25/14
to r-an...@googlegroups.com
I'm having trouble running the test code to confirm that the set up is correct. Here's what I'm getting. Does anyone have suggestions? Just to note: I already had Xcode installed and so I installed R and Rstudio after Xcode was already on laptop. Thanks!

> attributes::sourceCpp("test.cpp")  
/bin/sh: I/Library/Frameworks/R.framework/Resources/include: No such file or directory
make: [file9931325fb29.o] Error 127 (ignored)
/bin/sh: -dynamiclib: command not found
make: *** [file9931325fb29.so] Error 127
Error in dyn.load(basename(dynlib)) : 
  unable to load shared object '/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file9931325fb29.so':
  dlopen(/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file9931325fb29.so, 6): image not found
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file9931325fb29.cpp'' had status 1 

> attributes::sourceCpp("test.cpp", verbose=TRUE)  
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file99352c66c0f.cpp'
/bin/sh: I/Library/Frameworks/R.framework/Resources/include: No such file or directory
make: [file99352c66c0f.o] Error 127 (ignored)
/bin/sh: -dynamiclib: command not found
make: *** [file99352c66c0f.so] Error 127
I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -I"/Users/klostritto/Library/R/3.1/library/Rcpp11/include"      -c file99352c66c0f.cpp -o file99352c66c0f.o
-dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o file99352c66c0f.so file99352c66c0f.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in dyn.load(basename(dynlib)) : 
  unable to load shared object '/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file99352c66c0f.so':
  dlopen(/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file99352c66c0f.so, 6): image not found
In addition: Warning message:

> devtools::has_devel()
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD SHLIB foo.c 

gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -I"/Users/klostritto/Library/R/3.1/library/Rcpp11/include"   -fPIC  -mtune=core2 -g -O2  -c foo.c -o foo.o
gcc -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
[1] TRUE



Karen Lostritto

unread,
Jun 25, 2014, 1:05:22 PM6/25/14
to r-an...@googlegroups.com
Just to add: the entire piece of code I'm trying to run is below, and I'm stuck on second line.

writeLines( ' #include <Rcpp11> // [[export]] IntegerVector foo(){ return {1, 2, 3} ; } ', "test.cpp" ) 
attributes::sourceCpp("test.cpp")
 foo()

Kevin Ushey

unread,
Jun 25, 2014, 1:20:06 PM6/25/14
to r-an...@googlegroups.com
This is identical to the issue posted here:

    https://github.com/Rcpp11/Rcpp11/issues/207

so I think we need to figure out what's going on. What does `attributes::sourceCpp("test.cpp", verbose = TRUE)` give you?

Karen Lostritto

unread,
Jun 25, 2014, 1:22:17 PM6/25/14
to r-an...@googlegroups.com
Thanks for responding! Here is what I get:

> attributes::sourceCpp("test.cpp", verbose = TRUE)
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file99330b4777b.cpp'
/bin/sh: I/Library/Frameworks/R.framework/Resources/include: No such file or directory
make: [file99330b4777b.o] Error 127 (ignored)
/bin/sh: -dynamiclib: command not found
make: *** [file99330b4777b.so] Error 127
I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -I"/Users/klostritto/Library/R/3.1/library/Rcpp11/include"      -c file99330b4777b.cpp -o file99330b4777b.o
-dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o file99330b4777b.so file99330b4777b.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in dyn.load(basename(dynlib)) : 
  unable to load shared object '/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file99330b4777b.so':
  dlopen(/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpKDCG7T/file99330b4777b.so, 6): image not found
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file99330b4777b.cpp'' had status 1 



On Wednesday, June 25, 2014 10:03:43 AM UTC-7, Karen Lostritto wrote:

Kevin Ushey

unread,
Jun 25, 2014, 1:30:21 PM6/25/14
to r-an...@googlegroups.com
Romain, can we modify sourceCpp to capture the output of R CMD SHLIB and print that to the console as well? We need to be able to see what command R CMD SHLIB is trying to invoke.

Karen, are new lines getting removed from your call? Because the file written out should be structured as:

     #include <Rcpp11>
     // [[export]]
     IntegerVector foo(){ return {1, 2, 3} ; }

whereas running the code you gives dumps it all on one line (and hence would not compile as expected).

That said, it would still not lead to the error you are seeing so I am still confused.

Karen Lostritto

unread,
Jun 25, 2014, 1:36:45 PM6/25/14
to r-an...@googlegroups.com
When I ran it, I actually copied and pasted from here: http://blog.r-enthusiasts.com/2014/06/17/user2014-rcpp11-tutorial/
So it seems to be all on separate lines:

> readLines("test.cpp")
[1] "  "                     "#include <Rcpp11>"      ""                       "// [[export]]"         
[5] "IntegerVector foo(){  " "  return {1, 2, 3} ;"   "}"                      ""                     
Screen Shot 2014-06-25 at 10.34.28 AM.png

Kevin Ushey

unread,
Jun 25, 2014, 2:01:45 PM6/25/14
to r-an...@googlegroups.com
Hi Karen,

Can you try installing the latest version of attributes and running the code with 'verbose = TRUE' again, and telling me the output?

    devtools::install_github("Rcpp11/attributes")

    attributes::sourceCpp("test.cpp", verbose = TRUE)

Thanks for your patience!
Kevin

Karen Lostritto

unread,
Jun 25, 2014, 2:13:52 PM6/25/14
to r-an...@googlegroups.com
Here it is. Thanks for helping with this!

>     attributes::sourceCpp("test.cpp", verbose = TRUE)
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file10ba4b07fd2a.cpp'
I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include  -I"/Users/klostritto/Library/R/3.1/library/Rcpp11/include"      -c file10ba4b07fd2a.cpp -o file10ba4b07fd2a.o
-dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o file10ba4b07fd2a.so file10ba4b07fd2a.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
/bin/sh: I/Library/Frameworks/R.framework/Resources/include: No such file or directory
make: [file10ba4b07fd2a.o] Error 127 (ignored)
/bin/sh: -dynamiclib: command not found
make: *** [file10ba4b07fd2a.so] Error 127
Error in dyn.load(basename(dynlib)) : 
  unable to load shared object '/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpQEcaxZ/file10ba4b07fd2a.so':
  dlopen(/private/var/folders/00/15zlr000h01000cxqpysvccm004qyg/T/RtmpQEcaxZ/file10ba4b07fd2a.so, 6): image not found

Kevin Ushey

unread,
Jun 25, 2014, 2:17:13 PM6/25/14
to Karen Lostritto, r-an...@googlegroups.com
Thanks! The error is obvious now -- for some reason, the compiler is not getting propagated in the calls made by R CMD SHLIB.

As for the fix, that is less obvious at this point, so we'll have to figure out what's going on. Another user with the same problem had success by uninstalling R + RStudio, then reinstalling the latest version, but I still think this is something that _should_ work, so we'll investigate.


--
You received this message because you are subscribed to the Google Groups "R and C++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-and-cpp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karen Lostritto

unread,
Jun 25, 2014, 2:26:45 PM6/25/14
to r-an...@googlegroups.com, karen.l...@gmail.com
I did see that thread with the user who uninstalled and re-installed R and R studio, but I actually had not installed R and R studio on this particular laptop before this morning (and Xcode was on it previously), so not sure if that will help me...

Thanks!

Karen Lostritto

unread,
Jun 30, 2014, 1:58:04 AM6/30/14
to r-an...@googlegroups.com, karen.l...@gmail.com
Just to update: I uninstalled, and when I re-installed I chose the mavericks version rather than the snow leopard version of R, and now it's working. Not sure if that makes sense...
Reply all
Reply to author
Forward
0 new messages