开发者

How do I compile a c file with native functionality to connect via JNI? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably开发者_运维技巧 answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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 $@ $<
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜