How do I compile a c file with native functionality to connect via JNI? [closed]
I followed examples from java.sun.com to build sample jni app, but I've got problems. I intend to use unix with gcc. How do I compile *.c file with native function to have library? What parameters would I use? There are plenty of and I'm confused.
I use the following makefile to compile.
Just type make
from the command line.
TARGET = myagent
CC = gcc
# linux config
JDK = /usr/local/share/jdk1.6.0_20
CFLAGS=-Wall -I$(IDIR) -shared -DLINUX -I$(JDK)/include/linux -I$(JDK)/include
COMPILE = $(CC) $(CFLAGS) -c
OBJDIR = obj
SOURCES := $(wildcard *.c)
DEPS := $(wildcard *.h)
OBJFILES := $(addprefix $(OBJDIR)/, $(patsubst %.c, %.o, $(SOURCES)))
exe: $(OBJFILES)
$(CC) $(OBJFILES) -shared -o $(TARGET)
$(OBJDIR)/%.o : %.c $(DEPS)
$(COMPILE) -o $@ $<
精彩评论