Mail Archives: cygwin/2003/08/01/23:29:58
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 -