Pages

Wednesday, November 02, 2005

R/CDK install fails on GCC 4.0 systems

Some time ago Rajarshi Guha introduced R bindings for the CDK (see his CDK News articles), and today I tried to install his rcdk package that makes it happen.

However, it requires SJava which compiled fine on other machines, but not on my AMD64 machine. The problem seems to be related to the GNU GCC 4.0 compiler I have installed. Compiling with 3.4 works fine, but 4.0 complains with:

CtoJava.cweb:215: error: static declaration of 'std_env' follows non-static declaration
CtoJava.cweb:195: error: previous declaration of 'std_env' was here

Googling, learned me that I am not the only one with this problem, but did not find any solution. If you know how to fix this problem, please leave a message in the comments.

2 comments:

  1. The fix is pretty simple.

    Untar the SJava package and then open up
    SJava/src/RSJava/CtoJava.h

    Line 14 reads as

    extern JNIEnv *std_env; /* initialized in create_Java_vm */

    Change this to

    static JNIEnv *std_env; /* initialized in create_Java_vm */

    Go to the directory above SJava and then do

    R CMD build SJava

    followed by R CMD INSTALL SJava_0.68.tar.gz

    ReplyDelete
  2. On my AMD64 machine I had an additional problem: I needed to compile with the -fPIC compiler option (whatever that is). I saw this on several mailing lists too, so not uncommon. This option can be added to SJava/Makefile_rules.in.

    ReplyDelete