Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with inline and Xcode 4.2.1

I'm trying to get the inline package working on my macbook. The following block of code (from the cxxfunction examples) fails:

library(inline)
fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
    return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 )

With this error:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! make: g++-4.2: No such file or directory
make: *** [file141b5882.o] Error 1

This is strange, because g++ is available:

g++ -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

ls /usr/bin | grep gcc
gcc
i686-apple-darwin11-llvm-gcc-4.2
llvm-gcc
llvm-gcc-4.2

I've running Xcode 4.2.1, R 2.14.0, on Mac OS 10.7.2.

like image 638
Zach Avatar asked Dec 03 '11 15:12

Zach


1 Answers

After doing some research, it turns out this is an easy problem to fix:

sudo ln -sn /usr/bin/g++ /usr/bin/g++-4.2
sudo ln -sn /usr/bin/gcc /usr/bin/gcc-4.2

Inline and Rcpp seem to be working correctly now.

like image 135
Zach Avatar answered Oct 14 '22 21:10

Zach