Skip to content

[Rcpp-devel] Function does not compile on Mac OSX

5 messages · Romain Francois, Sacha Epskamp, Steve Lianoglou

#
Dear mailing list,

For a project I am working on speeding up a simulation in R by translating
it to C++ (using inline and Rcpp). It is done and works fine on my windows 7
64bit R, but for some reason it is not working on my supervisors latest mac
OSX (not sure of the version. should be up to date).

The strange thing is that it did work at first. It compiled and ran as
expected. We then proceeded by changing a few things, resulting in the
function not compiling anymore. When we then used exactly the same script as
before it suddenly did not work anymore. I get these errors:


Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created! file345af547.cpp: In
function ?SEXPREC* file345af547(SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*,
SEXPREC*, SEXPREC*)?:
file345af547.cpp:220: error: ISO C++ says that these are ambiguous, even
though the worst conversion for the first is better than the worst
conversion for the second:
/Library/Frameworks/R.framework/Versions/2.13/Resources/library/Rcpp/include/Rcpp/sugar/operators/minus.h:421:
note: candidate 1: Rcpp::sugar::Minus_Vector_Primitive<RTYPE, NA, T>
operator-(const Rcpp::VectorBase<RTYPE, NA, VECTOR>&, typename
Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 14, bool NA =
true, T = Rcpp::Vector<14>]
file345af547.cpp:220: note: candidate 2: operator-(SEXPREC*, int) <built-in>
file345af547.cpp:646: error: ISO C++ says that these are ambiguous, even
though the worst conversion for the first is better than the worst
conversion for the second:
/Library/Frameworks/R.framework/Versions/2.13/Resources/librar
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB
file345af547.cpp 2> file345af547.cpp.err.txt' had status 1

With relevant lines:

 220 : Demoplayers = Demoplayers - 1;

 646 : leeftijd = leeftijd + 1;

Demoplayers and leeftijd are both NumericVectors. Does anyone know if there
is a common bug on MacOSX that for some reason makes the inline compiler not
work anymore? The cxxfunction example works fine though.

Best,
Sacha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110516/e452a650/attachment.htm>
#
Hello,

Let's try to narrow this down.

Please provide a small and reproducible example.

What is the version of the compiler. This is what I have on my iMac:
$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

What version of Rcpp are you using. What version of R.

Romain

Le 16/05/11 12:06, Sacha Epskamp a ?crit :

  
    
#
Hi,

Here is a small example:


library("Rcpp")
library("inline")

fun <-cxxfunction(,
'
Environment e = Environment::global_env();
NumericVector bar = e["foo"];
bar = bar + 1;
return wrap(bar);
',plugin="Rcpp")

foo <- 1:10

fun()

This function works fine on my windows netbook, but does not work on my
supervisors mac. His computers specs are:

++++++++++

platform       i386-apple-darwin9.8.0
arch           i386
os             darwin9.8.0
system         i386, darwin9.8.0
status
major          2
minor          13.0
year           2011
month          04
day            13
svn rev        55427
language       R
version.string R version 2.13.0 (2011-04-13)


++++++++++++++

packageDescription('Rcpp')
Package: Rcpp
Title: Seamless R and C++ Integration
Version: 0.9.4


+++++++++++++++
Package: inline
Version: 0.3.8
Date: 2010-12-07
++++++++++++++++
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Best,
Sacha

2011/5/16 Romain Francois <romain at r-enthusiasts.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110516/ac72cd4f/attachment.htm>
#
And the error he gets is:

Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created! file786264e8.cpp: In
function ?SEXPREC* file786264e8()?:
file786264e8.cpp:33: error: ISO C++ says that these are ambiguous, even
though the worst conversion for the first is better than the worst
conversion for the second:
/Library/Frameworks/R.framework/Versions/2.13/Resources/library/Rcpp/include/Rcpp/sugar/operators/plus.h:451:
note: candidate 1: Rcpp::sugar::Plus_Vector_Primitive<RTYPE, NA, T>
operator+(const Rcpp::VectorBase<RTYPE, NA, VECTOR>&, typename
Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 14, bool NA =
true, T = Rcpp::Vector<14>]
file786264e8.cpp:33: note: candidate 2: operator+(SEXPREC*, int) <built-in>
make: *** [file786264e8.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB
file786264e8.cpp 2> file786264e8.cpp.err.txt' had status 1

2011/5/16 Sacha Epskamp <sacha.epskamp at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110516/adda394f/attachment-0001.htm>
#
Hi,

For what it's worth, your code works fine on my mac:

R> ... your code ...
R> fun()
 [1]  2  3  4  5  6  7  8  9 10 11

R> sessionInfo()
R version 2.13.0 Patched (2011-05-11 r55852)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
...

Also:

$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
...

I'm not sure how helpful that is, though, as it seems my system is a
bit different than your advisor's.

For instance, I'm running snow leopard (10.6), where it seems your
advisor is running Leopard (10.5)
I'm also running in 64bit mode, and your advisor is running 32bit. I'm
not sure if that's a big difference, but maybe he can force R to run
in 64bit as a test?

Oh .. I'm also running R 2.13.0 (Patched), which you can get here:
http://r.research.att.com/

In the row of that yellow table named "R-2.13-branch"

-steve
[snip]