cURL / Mailing Lists / curl-library / Single Mail

curl-library

jni_init() failure in libcurl from Java (JDK 1.3)

From: Serge Kruppa <serge.kruppa_at_simitel.com>
Date: Tue, 12 Mar 2002 23:47:52 -0600

I'm trying to use libcurl to access some Web pages over SSLv3. I have
re-compiled from scratch (under Cygwin, gcc, Windows 2000) OpenSSL and
libcurl, resulting in a libcurl.a of over 1.6MB in size. I didn't have to
modify any of the makefiles to get this result.

Now I'm trying to compile the Java interface provided and I'm facing serious
difficulties. After having modified the default Makefile to use the
appropriate include paths on my machine (see further below), I had trouble
compiling javacurl.c, gcc complaining about the __int64 found in the
declaration of jlong in jni_md.h. I replaced the __int64 declaration by
signed long and gcc compiled successfully.

But the most serious problem appears to be in the libjavacurl.dll file.
Firstly, the default LDFLAGS do not work under Cygwin, since the -G option
is not recognized. Replacing -G by -shared did allow the linking of
libjavacurl.dll (around 1.05MB in size). Running test.java I see that the
DLL is loaded successfully and jni_init() is executed in CurlGlue().
However, the application stops immediately after running jni_init() without
even an exception.

I have no idea why jni_init() is failing silently. I would appreciate any
feedback on things that I might have done wrong while producing
libjavacurl.dll, as well as any suggestion on how to resolve my issue. An
updated Makefile for Cygwin would also be most useful. Thanks in advance.

Best Regards,

Serge

+++ Makefile

TARGET = libjavacurl.dll

OBJS = javacurl.o

CC = gcc
CFLAGS = -c -v
CPPFLAGS
= -ID:/jdk/include -ID:/jdk/include/win32 -I./include -I/cygwin/usr/include

# Linux might use -shared -Wl,-soname,libnative.so instead of -G
LDFLAGS = -v -shared -L/cygwin/usr/lib -L. -lcurl -lssl -lcrypto

all: CurlGlue.h CurlGlue.class javacurl.o $(TARGET) test.class

test:
        java test

javacurl.o: javacurl.c CurlGlue.h
        $(CC) $(CPPFLAGS) $(CFLAGS) $<

CurlGlue.h: CurlGlue.java CurlGlue.class
        javah CurlGlue
        touch CurlGlue.h

test.class: CurlGlue.class javacurl.o
        javac test.java

CurlGlue.class: CurlGlue.java
        javac $<

$(TARGET): $(OBJS)
        $(CC) -o $(TARGET) $(OBJS) $(LDFLAGS)

clean:
        rm -f javacurl.o CurlGlue.h CurlGlue.class
Received on 2002-03-13