This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Compile JNI with autotools?


I am trying to compile some JNI code using the GNU autotools.
Could anyone recommend a simple example Makefile.am?

Currently, the final step in my compile process fails with the following error:

/bin/sh ../libtool --tag=GCJ --mode=link gcj  -g -O2   -o Test --main=Test Test.o libnewfmt_ptrnjava.la libnewfmt_ptrnjni.la -lz 
libtool: ignoring unknown tag GCJ
gcj -g -O2 -o .libs/Test --main=Test Test.o  ./.libs/libnewfmt_ptrnjava.so ./.libs/libnewfmt_ptrnjni.so -L/lib -lglib-2.0 -lz 
./.libs/libnewfmt_ptrnjava.so: undefined reference to `hidden alias for void FmtPtrn::helloWorld()'
collect2: ld returned 1 exit status
make: *** [Test] Error 1

Everything works find with the following, manual build commands:

$ javac FmtPtrn.java Test.java
$ java Test
Hello world!

Of course, in this case, the executable produced is not native.

Here are the relevant portions of my Makefile.am:

lib_LTLIBRARIES = libnewfmt_ptrn.la libnewfmt_ptrnjni.la libnewfmt_ptrnjava.la libnewtemplate.la

# JNI C Code:
libnewfmt_ptrnjni_la_SOURCES = fmt_ptrnjni.c
libnewfmt_ptrnjni_la_LDFLAGS = -version-info @VER_INFO@ $(GLIB_LIBS)

# JNI Java Code:
libnewfmt_ptrnjava_la_SOURCES = FmtPtrn.java

bin_PROGRAMS = new new_proj Test

Test_SOURCES = Test.java
Test_LDFLAGS = --main=Test
Test_LDADD = libnewfmt_ptrnjava.la libnewfmt_ptrnjni.la

-- 
Mike

:wq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]