Category: Uncategorized

  • Linking a static library to Java using JNI

    Beginning JNI Linux tutorial for Netbeans Once I had accomplished the above with complete success, I extended the experiment by linking my static library (.a) to the dynamic library, and calling the static library function from the dynamic library function. My HelloWorldNative.h:/* DO NOT EDIT THIS FILE – it is machine generated */#include <jni.h>/* Header…

  • Link java to a static library.

    See last post, assume testlib has a void hello(void) function. Step 1: Create a wrapper class.public class TestLibWrapper { public static native void hello(); static { System.loadLibrary(“testlib”); }} Step 2: Compile wrapper class.javac TestLibWrapper.java Step 3: Run javah to create C header and stub file.javah TestLibWrapper Step 4…

  • GNUmakefile for a basic library

    GNUmakefile for a static library, testlib.a, including a single file, hello.c OBJS = hello.o CFILES := ${OBJS:.o=.c}LDFLAGS =ARFLAGS = rcv all:: testlib.a testlib.a: ${OBJS} @$(AR) ${ARFLAGS} $@ $? clean:: @$(RM) ${OBJS} testlib.a