[Rcpp-devel] Rcpp module errors with Rcpp binary installation

Kevin Ushey kevinushey at gmail.com
Fri May 2 07:01:02 CEST 2014


Hi Ariful (sorry, I think I addressed you by your last name earlier),

clang does do things differently than gcc, so even though
std::function is a C++11 feature, I guess it 'leaks out' when
compiling even with -std=c++11 not specified. gcc doesn't have this
problem.

Unfortunately, there are ABI incompatibilities between gcc and clang.
So libraries built with one compiler set are not guaranteed to work
with the other (and, unfortunately, often don't). So don't be too
surprised when clang gives different warnings and errors from gcc.

On OS X Mavericks, you are best off using clang for all compilation --
I would recommend staying away from gcc. Of course, for older versions
of OS X you are stuck with the (old) version of gcc. But, because of
Apple's support, clang has become the de-facto compiler toolchain for
OS X, and this is reflected in the new build systems now on CRAN /
BioC.

If you choose to use gcc (or any custom compiler toolchain, really),
your best bet is probably to compile R and packages from source.
Alternatively, you might have to specify 'type="mac.binary"' (ie, "gcc
compatible") instead of 'type="mac.binary.mavericks"' (ie, "clang
compatible") in install.packages code to ensure you get compatible
binaries.

Cheers,
Kevin



On Thu, May 1, 2014 at 5:48 PM, Ariful Azad <azadcse at gmail.com> wrote:
> Thanks Kevin for the prompt reply.
> As a quick fix to the Bioconductor problem (2nd issue), I used
> Rcpp::function in the Rcpp module (replacing using namespace std will be
> more work at this point). I will have to wait till Saturday to see the build
> result. I am surprised that they don't have the error in other platforms
> except Maverick.
>
> It is possible that the first problem stems from library conflicts in my
> machine. But note that this problem only arises when:
> 1. I build Rcpp from binary
>
> This problem does not show up
> 1. when I build Rcpp from source code, or
> 2. when I build Rcpp from binary but there is no function declaration inside
> Rcpp module. (even Rcpp::function gives me the same error when Rcpp is built
> from binary).
>
>
> I will try to clean up my compiler toolchain and see if the problem can be
> removed. (I replaced clang++ with g++ for another reason. This process might
> create some problem).
>
> Thanks again for your help.
>
> --
>
> Ariful Azad
>
>
>
> On Thu, May 1, 2014 at 4:08 PM, Kevin Ushey <kevinushey at gmail.com> wrote:
>>
>> Actually, to confirm: this is exactly what the build report tells you
>> (with a lot of macro expansion in the support of Rcpp::function)...
>>
>> clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
>> -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include
>>
>> -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include"
>>   -fPIC  -Wall -mtune=core2 -g -O2  -c flowMatch.cpp -o flowMatch.o
>> flowMatch.cpp:74:2: error: reference to 'function' is ambiguous
>>         function( "computeMEC" , &computeMEC  , "Match clusters across
>> a pair of sample by mixed edge cover algorithm." ) ;
>>         ^
>>
>> /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include/Rcpp/module/Module_generated_function.h:28:6:
>> note: candidate found by name lookup is 'Rcpp::function'
>> void function( const char* name_,  OUT (*fun)(void), const char* docstring
>> = 0){
>>      ^
>>
>> ...
>>
>>
>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__functional_03:206:49:
>> note: candidate found by name lookup is 'std::__1::function'
>> template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
>>                                                 ^
>>
>> Clang does a good job of reporting error messages, so please learn how
>> to read them and what they are trying to tell you.
>>
>> Cheers,
>> Kevin
>>
>> On Thu, May 1, 2014 at 4:04 PM, Kevin Ushey <kevinushey at gmail.com> wrote:
>> > Hi Azad,
>> >
>> > Your first issue is something separate, probably due to clashing
>> > compiler toolchains between compiled versions of R / packages. If you
>> > want to dive into that further you'll need to give us some more
>> > information about your compiler setup.
>> >
>> > The second issue, with flowMatch, I believe this is because there is a
>> > clash between Rcpp::function (used for modules) and clang's
>> > std::function. You're probably running into this because you have
>> > 'using namespace std;' (which is bad practice btw -- please use
>> > typedefs for items in std:: you need, or qualify with std::
>> > explicitly).
>> >
>> > You might be able to work around it by qualifying with Rcpp::function
>> > explicitly.
>> >
>> > Cheers,
>> > Kevin
>> >
>> >
>> >
>> > On Thu, May 1, 2014 at 3:55 PM, Ariful Azad <azadcse at gmail.com> wrote:
>> >> Dear All,
>> >>
>> >> This question might be a repeat of an earlier question, but I will be
>> >> grateful if you can suggest any alternate solution to my problem.
>> >>
>> >> ------------
>> >> My system: Mac OS X 10.9 (Mavericks)
>> >> Rcpp Version: 0.11.1
>> >> R Version: 3.0.3
>> >> ----------------
>> >>
>> >> I installed Rcpp from binary using the install.package() function.
>> >> When I try to install a test package created by
>> >> Rcpp.package.skeleton('testModule', module=T)
>> >> I obtain the following error:
>> >>
>> >> *** installing help indices
>> >> ** building package indices
>> >> ** testing if installed package can be loaded
>> >> sh: line 1:  7195 Abort trap: 6
>> >> '/Library/Frameworks/R.framework/Resources/bin/R' --no-save --slave
>> >> 2>&1 <
>> >>
>> >> '/var/folders/pn/d49rpkj95v5_9g5q5bsz0k400000gn/T//RtmpwW5RU4/file1bff7d88ce2'
>> >> Warning: class "C++Object" is defined (with package slot ‘Rcpp’) but no
>> >> metadata object found to revise subclass information---not exported?
>> >> Making
>> >> a copy in package ‘testModule’
>> >> R(7195,0x7fff77cc8310) malloc: *** error for object 0x7fff77dd5330:
>> >> pointer
>> >> being freed was not allocated
>> >> *** set a breakpoint in malloc_error_break to debug
>> >> ERROR: loading failed
>> >>
>> >>
>> >> However, the error is gone when I install Rcpp from source. So far so
>> >> good
>> >> for me.
>> >> However, I have distributed my package through Bioconducor.org.
>> >> Bioconducor
>> >> is unable to build the package in Mac OS X 10.9 (Mavericks) (similarly
>> >> other
>> >> users of my package). They report the following error :
>> >>
>> >> flowMatch.cpp:74:2: error: reference to 'function' is ambiguous
>> >>         function( "computeMEC" , &computeMEC  , "Match clusters across
>> >> a
>> >> pair of sample by mixed edge cover algorithm." ) ;
>> >>
>> >> (the detail error can be found here
>> >>
>> >> from
>> >>
>> >> http://www.bioconductor.org/checkResults/release/bioc-LATEST/flowMatch/morelia-buildsrc.html
>> >>
>> >>
>> >> )
>> >> I don't know what Rcpp version they are using. It looks like they are
>> >> not
>> >> building Rcpp from source.  Is there any alternative suggestion to
>> >> avoid
>> >> this situation? (It may to be possible to instruct every users of the
>> >> package to install Rcpp from source).
>> >> The error is apparently coming from function declaration inside
>> >> RCPP_MODULE
>> >> function("hello" , &hello  , "documentation for hello ");
>> >> I disabled this line and the error is gone with Rcpp installed from
>> >> Binary
>> >> for the package created using install.package().
>> >>
>> >>
>> >> Notes 1: I do not see this error with Rcpp 0.10.5 installed from source
>> >> in
>> >> Mac OS X 10.9 (Mavericks)
>> >> Notes 2: I do not see this error with Rcpp 0.10.5 installed from binary
>> >> in
>> >> Mac OS X Snow Leopard (10.6.8).
>> >> Notes3: Bioconductor (I don't know their Rcpp version) successfully
>> >> built my
>> >> package on Linux (Ubuntu 12.04.4 LTS) / x86_64, Windows Server 2008 R2
>> >> Enterprise SP1 (64-bit) / x64 and Mac OS X Snow Leopard (10.6.8) /
>> >> x86_64 .
>> >> But their system was not able to build my package on Mac OS X Mavericks
>> >> (10.9.2) / x86_64
>> >>
>> >> The primary error they reported is
>> >>
>> >>
>> >>
>> >> flowMatch.cpp:74:2: error: reference to 'function' is ambiguous
>> >>         function( "computeMEC" , &computeMEC  , "Match clusters across
>> >> a
>> >> pair of sample by mixed edge cover algorithm." ) ;
>> >>
>> >> If you are interested, the detail error can be found:
>> >> from
>> >>
>> >> http://www.bioconductor.org/checkResults/release/bioc-LATEST/flowMatch/morelia-buildsrc.html
>> >>
>> >>
>> >>
>> >> Any suggestion to avoid this error in third party installation is much
>> >> appreciated.
>> >>
>> >> Regards,
>> >>
>> >> Ariful Azad
>> >> Post Doctoral Researcher
>> >> Lawrence Berkeley National Laboratory
>> >>
>> >>
>> >> _______________________________________________
>> >> Rcpp-devel mailing list
>> >> Rcpp-devel at lists.r-forge.r-project.org
>> >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>


More information about the Rcpp-devel mailing list