Re: Example on JNI compilation

2009-04-20 Thread LCID Fire

Ralf Wildenhues wrote:

Hello,

* LCID Fire wrote on Sat, Apr 18, 2009 at 11:08:58PM CEST:
I'm currently stuck with compiling a JNI library, which java does not  
recognize. I'm not too sure about what options I have to provide to  
automake and which are already builtin. Does anybody know an example of  
how a jni lib is built using automake?


How would one go about doing it without automake?

Like this:
gcc -c -fPIC myfile.c -o myfile.o
gcc -shared -lacl -Wl,-soname,mylib.so -o mylib.so myfile.o




Re: Example on JNI compilation

2009-04-20 Thread Ralf Wildenhues
* LCID Fire wrote on Mon, Apr 20, 2009 at 07:58:50PM CEST:
 Ralf Wildenhues wrote:
 * LCID Fire wrote on Sat, Apr 18, 2009 at 11:08:58PM CEST:
 I'm currently stuck with compiling a JNI library, which java does not 
  recognize. I'm not too sure about what options I have to provide to  
 automake and which are already builtin. Does anybody know an example 
 of  how a jni lib is built using automake?

 How would one go about doing it without automake?

 Like this:
 gcc -c -fPIC myfile.c -o myfile.o
 gcc -shared -lacl -Wl,-soname,mylib.so -o mylib.so myfile.o

I can't see anything JNI'ish or java'ish in the above, so, assuming
mylib.so is destined for $(pkglibdir),

  pkglib_LTLIBRARIES = mylib.la
  mylib_la_SOURCES = myfile.c
  mylib_la_LDFLAGS = -module -avoid-version
  mylib_la_LIBADD = -lacl

or I am still missing something that I haven't understood from your
request.

Cheers,
Ralf




Re: Example on JNI compilation

2009-04-20 Thread John Calcote

On 4/18/2009 3:08 PM, LCID Fire wrote:
I'm currently stuck with compiling a JNI library, which java does not 
recognize. I'm not too sure about what options I have to provide to 
automake and which are already builtin. Does anybody know an example 
of how a jni lib is built using automake?

There are basically two steps to building JNI libraries:

1. Use the javah utility to generate JNI prototypes in C-language header 
files from your Java source code.
2. Compile the C-language JNI sources (including the headers generated 
in step 1) into a library.


Step 1 above is pure Java-speak, and Automake has little built-in 
functionality for it. Step 2, however is pure gcc, and Automake has no 
trouble with it. For an example of how to integrate javah operations 
into Makefile.am so you can do it all from Automake, see Chapter 6 of 
this online book at freesoftwaremagazine.com:


  http://www.freesoftwaremagazine.com/books/agaal/autotools_example

Search for the text, Building the JNI C++ sources.

Regards,
John




Re: Example on JNI compilation

2009-04-20 Thread Andreas Otto
Am Samstag 18 April 2009 23:08:58 schrieb LCID Fire:
 I'm currently stuck with compiling a JNI library, which java does not
 recognize. I'm not too sure about what options I have to provide to
 automake and which are already builtin. Does anybody know an example of
 how a jni lib is built using automake?

Hi,

  in my project:   

http://libmsgque.sourceforge.net/
 
  you can find a implementation useable as template

  1. download the sources
  2. go into the javamsgque directory
  3. don't forget to add the autoconf macros for JNI
from the m4 subdirectory and the acinclude.m4 file


mfg

  Andreas Otto




Re: Example on JNI compilation

2009-04-18 Thread Ralf Wildenhues
Hello,

* LCID Fire wrote on Sat, Apr 18, 2009 at 11:08:58PM CEST:
 I'm currently stuck with compiling a JNI library, which java does not  
 recognize. I'm not too sure about what options I have to provide to  
 automake and which are already builtin. Does anybody know an example of  
 how a jni lib is built using automake?

How would one go about doing it without automake?

Cheers,
Ralf