From owner-freebsd-java Wed Jul 28 21: 9: 0 1999 Delivered-To: freebsd-java@freebsd.org Received: from bahay.rn.byu.edu (bahay.rn.byu.edu [128.187.221.77]) by hub.freebsd.org (Postfix) with ESMTP id 0DDA615569 for ; Wed, 28 Jul 1999 21:08:53 -0700 (PDT) (envelope-from larsene@bahay.rn.byu.edu) Received: from bahay.rn.byu.edu (localhost [127.0.0.1]) by bahay.rn.byu.edu (8.9.3/8.9.2) with ESMTP id WAA00356 for ; Wed, 28 Jul 1999 22:06:35 -0600 (MDT) (envelope-from larsene@bahay.rn.byu.edu) Message-ID: <379FD34A.DEBADA13@bahay.rn.byu.edu> Date: Wed, 28 Jul 1999 22:06:34 -0600 From: "E. Scott Larsen" X-Mailer: Mozilla 4.6 [en] (X11; I; FreeBSD 3.2-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-java@freebsd.org Subject: jni Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I'm looking into using the JNI for an upcoming project, and hava a question about using on FreeBSD. I'm doing a very simple example (code for each file is below) from the Essential JNI (Rob Gordon, Prentace Hall...). I'm running FreeBSD-3.2-Stable about a week old; jdk1.1.8 just re-installed fresh this morning from cvsup'd ports, and using the csh: > cd /home/larsene/jni > setenv LD_LIBRARY_PATH /home/larsene/jni:/usr/lib:/usr/local/lib > rm *.o lib* > g++ -c -fPIC *.c -I$JDK/include -I$JDK/include/freebsd > g++ -shared -o libmylib.so -fPIC *.o > java main /usr/lib/libg++.so.4: Undefined symbol "__pure_virtual" (libmylib.so) my error > I assume the problem is something missing from that LD..PATH setting, or perhaps a compiler flag. Anyone got a quick tip or a pointer to somewhere I aught to look? Thanks tons!!! // file: main.java public class main { static { try { System.loadLibrary("mylib"); } catch (Error e) { System.out.println("my error"); System.exit(0); } } public static void main(String[] args) { aclass c = new aclass(); c.theNativeMethod(); } } //file: aclass.java public class aclass { public native void theNativeMethod(); public void aJavaMethod() { theNativeMethod(); } } //file: aclass.c #include #include "aclass.h" JNIEXPORT void JNICALL Java_aclass_theNativeMethod (JNIEnv* env, jobject thisObj) { printf("Hello Scott World\n"); } //file: aclass.h ////generated by >javac aclass.java ; javah -jni aclass /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class aclass */ #ifndef _Included_aclass #define _Included_aclass #ifdef __cplusplus extern "C" { #endif /* * Class: aclass * Method: theNativeMethod * Signature: ()V */ JNIEXPORT void JNICALL Java_aclass_theNativeMethod (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message