Call Java functions in a C DLL

A

Ahmad Jalil Qarshi

Hi,

I am develop a dynamic link library in C on AIX that will internally
call java functions using JNI. This libaray will be finally used by
other C Executable.

There is only one function in C code i.e. Connect. This function
internally use JNI and call java functions. Now while compiling I am
facing problems. I think that there is some problem with my makefile.

The make file is given hereunder:

JAVA_HOME = /usr/java14
JAVA_INC = $(JAVA_HOME)/include

CC = cc
LD = cc

# Flags to create a dynamic library.
DYNLINKFLAGS = -G -ostdlib -bnoentry -bM:SRE -brtl -bE:Interface.exp

# files removal
RM = rm -f

#------------------------------------- Libs
-----------------------------------#
JAVALIBS = -L$(JAVA_HOME)/jre/bin/classic/
LIBS = -ljvm -lpthread -lxnet -lnsl -lm -ldl
#-------------------------------- Dependency
rules---------------------------#
# shared library files
LIB_FILES = Interface.a
#-------------------------------------
OBJs-------------------------------------#
# shared libraries object files
LIB_OBJS = Interface.o

all: $(LIB_FILES)
# create our librarys
Interface.a: Interface.o
$(LD) $(DYNLINKFLAGS) $(JAVALIBS) $(LIBS) $(LIB_OBJS) -o $@

# compile C source files into object files.
%.o: %.c
$(CC) $(DYNLINKFLAGS) -L$(JAVA_INC) -c $<

# clean everything
clean:
$(RM) $(LIB_OBJS) $(LIB_FILES)

# clean the library's object files only
cleanlibobjs:
$(RM) $(LIB_OBJS)



Now the problem is that library is not properly created because the
size of the Interface.a file is very small only 552 bytes. whereas the
size of Interface.o file is 34428. Which clearly indicates that the
problem is with the Interface.a file i.e during linking.

Can any body help me to figure out the problem.

Regards,

Ahmad Jalil Qarshi
 
F

Flash Gordon

Ahmad Jalil Qarshi wrote, On 20/10/08 23:33:

There is only one function in C code i.e. Connect. This function
internally use JNI and call java functions. Now while compiling I am
facing problems. I think that there is some problem with my makefile.

<snip>

Make files are not topical on comp.lang.c nor is how to interface to
Java (because it is JAva that specifies this not C). Please keep the
discussion of this on groups where it is topical, and I'm guessing that
comp.unix.programmer and/or comp.unix.aix might be appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top