Mail Archives: cygwin/2004/06/16/11:53:20
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 -