From owner-freebsd-java Fri Dec 31 16: 7:39 1999 Delivered-To: freebsd-java@freebsd.org Received: from ns1.1connect.com (216-59-79-65.usa2.flashcom.net [216.59.79.65]) by hub.freebsd.org (Postfix) with ESMTP id 1C7C714C9A; Fri, 31 Dec 1999 16:07:33 -0800 (PST) (envelope-from keith@1connect.com) Received: from 1connect.com ([10.0.0.75]) by ns1.1connect.com (8.9.3/8.9.1) with ESMTP id QAA71491; Fri, 31 Dec 1999 16:06:58 -0800 (PST) (envelope-from keith@1connect.com) Message-ID: <386D454B.694B5093@1connect.com> Date: Fri, 31 Dec 1999 16:07:40 -0800 From: Keith Wong X-Mailer: Mozilla 4.7 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-java@freebsd.org, freebsd-questions@freebsd.org Subject: java JNI compile problems Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 /* 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 #include "HelloWorld.h" #include 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