Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Dec 1999 20:27:00 -0600 (CST)
From:      Tim Zingelman <tez@nova.fnal.gov>
To:        Keith Wong <keith@1connect.com>
Cc:        freebsd-java@FreeBSD.ORG
Subject:   Re: java JNI compile problems
Message-ID:  <Pine.GSO.4.10.9912312014020.12351-100000@nova.fnal.gov>
In-Reply-To: <386D454B.694B5093@1connect.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Keywords: java JNI gcc compile build shared undefined main lib library

To build a shared library you will want to use -fpic & -shared

% gcc -fpic -shared -g -I/usr/local/jdk1.1.8/include/
-I/usr/local/jdk1.1.8/include/freebsd HelloWorldImp.c
-o libhello.so

The -g just adds debug info... -fpic makes it position independent and
-shared makes it a shared library.  Also if you are running an older
(non-ELF) machine, you will need to add the -aout flag to build compatible
libraries.

 - Tim

On Fri, 31 Dec 1999, Keith Wong wrote:

> 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.
> Keith
> 
> % 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?Pine.GSO.4.10.9912312014020.12351-100000>