delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/06/16/11:53:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Reply-To: Cygwin List <cygwin AT cygwin DOT com>
Message-Id: <6.1.0.6.0.20040616105354.032960d8@pop.prospeed.net>
X-Sender:
Date: Wed, 16 Jun 2004 11:44:55 -0400
To: Andrew Hinton <ug60axh_andy AT yahoo DOT co DOT uk>, cygwin AT cygwin DOT com
From: Larry Hall <cygwin-lh AT cygwin DOT com>
Subject: Re: JNI loading dlls which link to cygwin1.dll
In-Reply-To: <20040616122319.28230.qmail@web50103.mail.yahoo.com>
References: <20040616122319 DOT 28230 DOT qmail AT web50103 DOT mail DOT yahoo DOT com>
Mime-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i5GFrJMD008321

At 08:23 AM 6/16/2004, you 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


<snip>


>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?


Your C/C++ code seems to assume a POSIX environment.  You
don't get that from Windows.  So you'll need to compile 
your C/C++ code *without* '-mno-cygwin' if you don't want 
to do some porting.  

I know very little about Java but I'm assuming you're trying
to load the C/C++ DLLs you make with JNI.  If that's true and 
you want to try to avoid porting, you might find this link 
interesting <http://sources.redhat.com/ml/cygwin/2004-06/msg00274.html>.
Basically, cygwin1.dll won't be properly initialized if it's loaded 
from a non-Cygwin program.  So you'll need to try a little 
wizardry to make this work.  Or you could submit a patch to 
make this work for everyone using other magic. ;-)



--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019