开发者

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

开发者 https://www.devze.com 2023-04-05 12:09 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably开发者_运维技巧 answered in its current form.
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

精彩评论

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