Date: Fri, 31 Dec 1999 16:07:40 -0800 From: Keith Wong <keith@1connect.com> To: freebsd-java@freebsd.org, freebsd-questions@freebsd.org Subject: java JNI compile problems Message-ID: <386D454B.694B5093@1connect.com>
next in thread | raw e-mail | index | archive | help
Hi All, I want to use the java JNI to integrated with C. And, i tried to follow the example at the java.sun's website. then I get the problem when I try to compile the shared the library using gcc -g, then i get the error. i don't know is the -g parameter that i used it's right or not. the error i got are: /usr/lib/crt1.o: In function `_start': /usr/lib/crt1.o(.text+0x69): undefined reference to `main' I try the same step at Win98 with Visual C++ and it worked with no problems. May be I need the right parameter. Is the JNI work at Freebsd? Thanks for the help!! Here are the source. Keith HelloWorld.java ****************************************** class HelloWorld { public native void displayHelloWorld(); static { System.loadLibrary("hello"); } public static void main(String[] args) { new HelloWorld().displayHelloWorld(); } } ****************************************** %javac HelloWorld.java %javah -jni HelloWord HelloWorld.h ******************************************* /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class HelloWorld */ #ifndef _Included_HelloWorld #define _Included_HelloWorld #ifdef __cplusplus extern "C" { #endif /* * Class: HelloWorld * Method: displayHelloWorld * Signature: ()V */ JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif ***************************************************** HelloWorldImp.c ******************************************************* #include <jni.h> #include "HelloWorld.h" #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf("Hello world!\n"); return; } ******************************************************** % gcc -g -I/usr/local/jdk1.1.8/include/ -I/usr/local/jdk1.1.8/include/freebsd HelloWorldImp.c -o libhello.so /usr/lib/crt1.o: In function `_start': /usr/lib/crt1.o(.text+0x69): undefined reference to `main' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?386D454B.694B5093>