JNI loading dlls which link to cygwin1.dll

Ronald Landheer-Cieslak ronald@landheer.com
Wed Jun 16 17:22:00 GMT 2004


Have a look at the thread that starts here:
http://sources.redhat.com/ml/cygwin/2003-03/msg00795.html

If that doesn't help you, please report back :)

(In short, that thread lead to the conclusion that there was a problem 
with the calling convention used. Your linker flag to add stdcall 
versions of the functions is not too far off the final result).

HTH

rlc

Andrew Hinton wrote:

> I have been attempting to port a large program from
> Linux to Windows using Cygwin.  The program is written
> in Java, C and C++; using the JNI to link them
> together.
> 
> I have successfully compiled and linked all of the C
> and C++ code using Cygwin, and successfully executed a
> test program written in C++. 
> 
> The following illustrates the compiler flags I was
> using:
> 
> g++ -c -D__int64="long long" ###includes### *.cc
> gcc -Wl,--add-stdcall -shared -o ~/prism/lib/file.dll
> *.o -L ~/prism/lib -lutil -lepd
> 
> The problem comes when the JNI tries to load the
> shared dlls in the loadLibrary() method.  The JNI
> appears to be able to find the libraries, as no
> UnsatisfiedLinkError is reported; however, the
> execution halts, giving no output.  
> 
> It appears that JNI has problems with cygwin1.dll,
> because I have had no JNI problems with dlls not
> created using Cygwin.
> 
> After searching the Internet and this mailing list,
> most sources seem to point out that I should use the
> -mno-cygwin compiler flag.  This appears to remove the
> need for the cygwin1.dll at runtime.  However, this
> results in compile errors.  For example:
> 
> $ gcc -c -D__int64="long long" -I../mnemosyne/ *.c
> 
> This works fine Â… but this doesnÂ’t:
> 
> $ gcc -mno-cygwin -c -D__int64="long long"
> -I../mnemosyne/ *.c
> datalimit.c:17:26: sys/resource.h: No such file or
> directory
> pipefork.c:12:22: sys/wait.h: No such file or
> directory
> test-res.c:5: error: syntax error before '(' token
> test-res.c:9: error: syntax error before '{' token
> test-res.c:13: error: conflicting types for `prog'
> test-res.c:11: error: previous declaration of `prog'
> test-res.c:13: warning: data definition has no type or
> storage class
> test-res.c:14: error: syntax error before "if"
> test-res.c:16: error: syntax error before numeric
> constant
> test-res.c:16: error: conflicting types for `exit'
> /usr/i686-pc-mingw32/include/stdlib.h:357: error:
> previous declaration of `exit'
> test-res.c:16: warning: data definition has no type or
> storage class
> test-res.c:18: error: syntax error before string
> constant
> test-res.c:18: error: conflicting types for
> `util_restart'
> util.h:240: error: previous declaration of
> `util_restart'
> test-res.c:18: warning: data definition has no type or
> storage class
> test-res.c:20: error: initializer element is not
> constant
> test-res.c:20: warning: data definition has no type or
> storage class
> test-res.c:21: error: syntax error before "void"
> test-res.c:25: error: syntax error before '!=' token
> test-res.c:30: error: redefinition of `i'
> test-res.c:20: error: `i' previously defined here
> test-res.c:30: warning: data definition has no type or
> storage class
> test-res.c:31: error: syntax error before "for"
> test-res.c:31: error: syntax error before '!=' token
> 
> 
> 
> The problem seems to be that a lot of the program uses
> routines that (I think) are not part of the windows
> API, specifically the following headers are used:
> 
> sys/files.h
> sys/file.h
> stream.h
> unisd.h
> sys/time.h
> sys/resource.h
> sys/times.h
> types.h
> times.h
> sys/wait.h
> a.out.h
> pwd.h
> 
> I have searched the Internet, the Cygwin manual and
> CygwinÂ’s FAQ and I have found nothing that explains
> the problem with JNI and cygwin1.dll.  Could anyone
> either point me in the right direction or say whether
> I am doing anything wrong.  Or does anyone know if
> there is a way to make this work without the need for
> the cygwin1.dll?
> 
> I have attached the cygcheck file.
> 
> Thanks,
> 
> Andrew Hinton
> 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list