delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/08/01/23:29:58

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Spam-Filter: check_local AT alphatech DOT com 4.4(020923:1754) http://digitalanswers.org/
Message-Id: <4.3.2.7.2.20030801202215.026caf70@mail.alphatech.com>
X-Sender: alant AT mail DOT alphatech DOT com
Date: Fri, 01 Aug 2003 20:29:30 -0700
To: cygwin AT cygwin DOT com
From: Alan Thompson <athompson AT alphatech DOT com>
Subject: Re: loading DLLs created with Cygwin into Sun JDK
In-Reply-To: <3F2B292B.3020600@santafe.edu>
Mime-Version: 1.0

Ok, if you check out this example:  http://www.whitecaps.net/jni/expr.jar  

you'll see that there it doesn't use -mno-cygwin.  Here is the g++ task from the ant build script:

  <property name="cppCompilerName" value="g++" />

    <echo message="Compiling for Cygwin..." /> 
    <exec executable="${cppCompilerName}" dir="${ctmp}" > 
      <arg line="-D_REENTRANT -D_GNU_SOURCE -D__int64='long long' "  /> 
      <arg line="-I${env.JAVA_HOME}/include" /> 
      <arg line="-I${env.JAVA_HOME}/include/win32" /> 
      <arg line="-I${basedir}/src" /> 
      <arg line="-c " /> 
      <arg line=" HelloWorld.c" /> 
    </exec> 

    <echo message="Linking for Cygwin..." /> 
    <exec executable="${cppCompilerName}" dir="${ctmp}" > 
      <arg line=" -Wl,--add-stdcall-alias -shared" /> 
      <arg line="-I${env.JAVA_HOME}/include" /> 
      <arg line="-I${env.JAVA_HOME}/include/win32" /> 
      <arg line="-I${basedir}/src" /> 
      <arg line="  " /> 
      <arg line="-o ${bin}/Native.dll" /> 
      <arg line=" HelloWorld.o" /> 
    </exec> 
.....
  <target name="go" depends="build" >
    <java classname="HelloWorld" classpath="${bin}" fork="true"> 
      <jvmarg line="-Xms64m -Xmx256m" /> 
      <jvmarg line="-Djava.library.path=${bin}" /> 
    </java> 
    <antcall target="clean" /> 
  </target>

Works for me!

===============================================================
> ant
Buildfile: build.xml
.............
ccComp:
    [mkdir] Created dir: C:\work\test\expr\jni\hello\ctmp
     [copy] Copying 2 files to C:\work\test\expr\jni\hello\ctmp

     [echo] Compiler Name:     g++
     [echo] Compiler Version:
     [exec] g++ (GCC) 3.2 20020927 (prerelease)
     [exec] Copyright (C) 2002 Free Software Foundation, Inc.
     [exec] This is free software; see the source for copying conditions.  There is NO
     [exec] warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     [echo] Compiling for Cygwin...
     [echo] Linking for Cygwin...
go:
     [java] loading library
.........
     [java] answer[ 0 ] = 'Hello World from C!'
     [java] answer[ 1 ] = 'the new C string value'
     [java] answer[ 2 ] = 'initial value from java'
BUILD SUCCESSFUL
Total time: 17 seconds
>
===============================================================

At 08:59 PM 8/1/2003 -0600, Marcus G. Daniels wrote:

>Again, "those techniques" specify use of -mno-cygwin, which worked fine for me in my posted example.  The crash happens as the DLL is loaded, not when methods are called.
>
>Have you actually tried _not_ using -mno-cygwin?
>
>Also, using 'javah' or not to generate the headers (and making sure JNIEXPORT and
>JNICALL are in the header and implementation declarations, and using
>and using -Wl,--add-stdcall-alias makes no difference.  For this simple test case, you need to have JNIEXPORT/JNICALL and the -Wl,--add-stdcall-alias, or neither to get the test case to work.  



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