Skip to content

RJava lib error

4 messages · Vahid Pazirandeh, Brian Ripley, Duncan Temple Lang

#
Hello all!

I recently install R-1.2.3 and Omegahat SJava pkg
(formely Java pkg) 0.62 and tried running the examples
by issuing "scripts/RJava --example --gui=none" and I
got the following:

Error in dyn.load(x, as.logical(local),
as.logical(now)) : 
        unable to load shared library
"/usr/lib/R/library/ctest/libs/ctest.so":
  ld.so.1:
/usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java:
fatal: relocation error: file
/usr/lib/R/library/ctest/libs/ctest.so: symbol MAIN__:
referenced symbol not found
[omegahat->R] 
SIGSEGV   11*  segmentation violation


I've been trying to figure this problem out for a
while, but I haven't had any luck yet.  This occurs
for any R-Java program I run.. i install it onto two
different machines and they both yielded the same
errors:

1) 5.8 Generic sun4u sparc SUNW,Ultra-5_10
2) 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-2

Any assistance would be much appreciated.. I am truely
a newbie!  

Please replyto: vpaziran at yahoo.com

regards,
v


=====
< Education Center on Computational Science and Engineering >
< http://edcenter.sdsu.edu >
=====

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 19 Jun 2001, Vahid Pazirandeh wrote:

            
Solaris, right?
Something is wrong with your R build, I think, as on my Solaris 2.7
system MAIN__ is not a symbol in ctest.so.

As a temporary fix, alter R_HOME/library/base/R/Rprofile to omit

.First <- function() {
    require("ctest", quietly=TRUE)
}

adn see if this allows you to proceed.
#
Usually when I see an error about a missing symbol in ctest.so
it indicates 
  a) that I am running R embedded in another application.
    In this case the example runs Java and then loads R into it.
  b) The ctest package (and the other packages) were not recompiled
     to be linked against libR.so 

The problem is that ctest.so needs to be linked against libR.so to
find the symbols in R.  As Brian points out, MAIN_ is not a symbol it
looks for, so something more fundamental may be wrong.

Usually, ctest.so not being linked against libR.so happens when one
first builds R without the --enable-R-shlib configuration and then
afterwards, you reconfigure and rebuild with that option. The package
libraries do not get rebuilt and hence do not pick up the newly added
instructions to link with libR.so.


Brian's suggestion is the simplest fix - simply avoid loading
the ctest library.

The longer term fix is to recompile all of the packages.
The failsafe and slow way to do this is 
   cd $R_HOME
   make distclean
   ./configure --enable-R-shlib
   make

The quick shortcut is to remove the ctest.so in
both 
  $R_HOME/src/library/ctest/src/
and
  $R_HOME/library/ctest/libs

and then re-build the library.

The commands are

  rm $R_HOME/library/ctest/libs/ctest.so
  rm $R_HOME/library/ctest/libs/ctest.so
  rm src/ctest.so
  cd $R_HOME/src/library/ctest

Hope this helps.
  D.
Prof Brian D Ripley wrote:

  
    
#
Hello Brian and Duncan,

Brian: I ommited what you said, and now it does work! 
When I hit return in the scripts/RJava --example
--gui=none I get segmentation fault (is it supposed to
be that way?); however, if I input R statements
("sum(1:3)") it does work.  I attached the complete
error I receive at the end of my reply.  

Duncan, I was reading your "Calling R from Java" paper
dated January 31, 2001 and tried to make a very basic
Java program to send an R statement and receive the
object back and display it to the user, but was
unsuccessful (probably because I have not used both R
and Java enough to understand the underlying
fundamentals involved).  Here is the "bla.java" file:

--- snip snip ---
import java.io.*;
import org.omegahat.R.Java.*;

public class bla {
    public static void main(String args[]) {
        System.out.println("Hello...");
        REvaluator e = new REvaluator();
        Object val = e.eval("objects()");
        String[] objects = (String[])val;
        for (int i=0; i < objects.length; i++) {
            System.out.println(i + ": " + objects[i]);
        }
    }
}
--- snip snip ---



Here are some cases I try to run the program:

/home/swbdev> java bla
Hello...
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no SJava in
java.library.path
        at java.lang.Throwable.fillInStackTrace(Native
Method)
        at
java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Error.<init>(Error.java:50)
        at
java.lang.LinkageError.<init>(LinkageError.java:43)
        at
java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
        at java.lang.ClassLoader.loadLibrary(Compiled
Code)
        at
java.lang.Runtime.loadLibrary0(Runtime.java:471)
        at
java.lang.System.loadLibrary(System.java:745)
        at <Unloaded Method>
        at bla.main(Compiled Code)


/home/swbdev> echo $LD_LIBRARY_PATH
/home/swbdev/R-1.2.3/lib/R/library/SJava/libs:/usr/bin/../java/bin/../jre/lib/sparc


/home/swbdev> ls -l
/home/swbdev/R-1.2.3/lib/R/library/SJava/libs
total 618
-rwxr-xr-x   1 swbdev     391400 Jun 19 09:36 SJava.so
lrwxrwxrwx   1 swbdev          8 Jun 19 09:37
libRInterpreter.so -> SJava.so
-rwxr-xr-x   1 swbdev     213496 Jun 19 09:36
libRSNativeJava.so
lrwxrwxrwx   1 swbdev          8 Jun 19 09:37
libSJava.so -> SJava.so
/home/swbdev> 


As you see the libraries for SJava are in my
LD_LIBRARY_PATH.. and unsetting it did not work
either:

/home/swbdev> unset LD_LIBRARY_PATH
/home/swbdev> java bla
Hello...
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no SJava in
java.library.path
        at java.lang.Throwable.fillInStackTrace(Native
Method)
        at
java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Error.<init>(Error.java:50)
        at
java.lang.LinkageError.<init>(LinkageError.java:43)
        at
java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
        at java.lang.ClassLoader.loadLibrary(Compiled
Code)
        at
java.lang.Runtime.loadLibrary0(Runtime.java:471)
        at
java.lang.System.loadLibrary(System.java:745)
        at <Unloaded Method>
        at bla.main(Compiled Code)


I finally copied scripts/RJava to the same dir as
bla.class/bla.java are in, and modified it so that the
last line to read:

#${JAVA} -classpath $CLASSPATH ${OMEGA_PROPS} ${CLASS}
$ARGS
${JAVA} -classpath $CLASSPATH ${OMEGA_PROPS} bla $ARGS

and ran it:


/home/swbdev> ./RJava 
Hello...
Segmentation Fault
    si_signo [11]: Segmentation Fault
    si_errno [0]: Error 0
    si_code [1]: SEGV_MAPERR [addr: 0xc]

        stackpointer=FFBED748
"Finalizer" (TID:0x122a2c, sys_thread_t:0x1229b0,
state:CW, thread_t: t at 6, threadID:0xfece1dd8,
stack_bottom:0xfece2000, stack_size:0x20000) prio=8

[1]
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:106)
[2]
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:128)
[3]
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:175)
-------------------
"Reference Handler" (TID:0x12cea4,
sys_thread_t:0x12ce28, state:CW, thread_t: t at 5,
threadID:0xfed11dd8, stack_bottom:0xfed12000,
stack_size:0x20000) prio=10

[1] java.lang.Object.wait(Object.java:424)
[2]
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:107)
-------------------
"Signal dispatcher" (TID:0x11fe34,
sys_thread_t:0x11fdb8, state:MW, thread_t: t at 4,
threadID:0xfed41dd8, stack_bottom:0xfed42000,
stack_size:0x20000) prio=10

-------------------
"main" (TID:0x3b26c, sys_thread_t:0x3b1f0, state:R,
thread_t: t at 1, threadID:0x25200,
stack_bottom:0xffbf0000, stack_size:0x20000) prio=5
*current thread*

[1] org.omegahat.R.Java.REvaluator.eval(Native Method)
[2]
org.omegahat.R.Java.REvaluator.eval(REvaluator.java:86)
[3]
org.omegahat.R.Java.REvaluator.eval(REvaluator.java:36)
[4] bla.main(bla.java:6)
-------------------
Abort




This Segmentation Fault is the same segfault received
when I hit the return key in the "scripts/RJava
--example --gui=none" with no statement typed (blank
line, just hit return).

I have much to learn it seems.

regards,
vahid








--- Duncan Temple Lang <duncan at research.bell-labs.com>
wrote:
/usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java:
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
_______________________________________________________________
=====
< Education Center on Computational Science and Engineering >
< http://edcenter.sdsu.edu >
=====

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._