Linking SUN OS 4.1.3 C code routines

Brian Fox bfox at opti.com
Mon Mar 24 15:27:13 PST 1997


I have just recently started using kaffe and have run into a problem
using native functions.  I can not seem to link the C code into the
Java code.  Do I need to put my C routines into a special directory or
to do something different with LD_LIBRARY_PATH?  Any help would be 
appreciated.

My environment variables are set to:
CLASSPATH=.:/usr/local/share/kaffe/classes.zip:/usr/local/share/kaffe/biss.zip
LD_LIBRARY_PATH=/home/hobie2/bfox/java/stand/temp:/usr/local/lib
KAFFEHOME=/usr/local/share/kaffe:.

All of the files are in /home/hobie2/bfox/java/stand/temp.

I am using SUN OS 4.1.3 on a Sparc with Kaffe 0.8.3 and Gcc 2.7.2

I compiled and linked the code with:
gcc -g -c *.c -I/usr/./local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/include -I/usr/local/include/kaffe
ld -o libhello.so *.o

Command line:
kaffe Main

Error message:
java.lang.UnsatisfiedLinkError: no hello in shared library path
        at java/lang/Throwable.<init>(line unknown, pc 6d860)
        at java/lang/Error.<init>(line unknown, pc 6d734)
        at java/lang/LinkageError.<init>(line unknown, pc 6d644)
        at java/lang/UnsatisfiedLinkError.<init>(line unknown, pc 6d5bc)
        at java/lang/Runtime.loadLibrary(line unknown, pc 5f6a8)
        at java/lang/System.loadLibrary(line unknown, pc 5d674)
        at HelloWorld.<clinit>(5)
        at Main.main(3)

Main.java:
class Main {
   public static void main(String[] args) {
      new HelloWorld().displayHelloWorld();
   }
}

HelloWorld.java:
class HelloWorld {
   public native void displayHelloWorld();

   static {
      System.loadLibrary("hello");
   }
}

HelloWorld.c:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <StubPreamble.h>

/* Stubs for class HelloWorld */
/* SYMBOL: "HelloWorld/displayHelloWorld()V", Java_HelloWorld_displayHelloWorld_stub */
stack_item *Java_HelloWorld_displayHelloWorld_stub(stack_item *_P_,struct execenv *_EE_) {
	extern void HelloWorld_displayHelloWorld(void *);
	(void) HelloWorld_displayHelloWorld(_P_[0].p);
	return _P_;
}

HelloWorldImp.c:
#include <StubPreamble.h>
#include "HelloWorld.h"
#include <stdio.h>

void HelloWorld_displayHelloWorld(struct HHelloWorld *this) {
   printf("Hello World from C\n");
   return;
}



More information about the kaffe mailing list