This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
1.3.3-2: Standard out writes fail after cygwin generated dll loaded
- To: cygwin at cygwin dot com
- Subject: 1.3.3-2: Standard out writes fail after cygwin generated dll loaded
- From: Aj Lavin <aj at haightmail dot org>
- Date: Sat, 13 Oct 2001 04:00:52 -0700
I used cygwin 1.3.3-2 under Windows 2000 to create a JNI dll which I
then loaded in a java Application.
When run in a DOS shell, the java Application succeeds in writing to
standard output up until the point when the dll is loaded. All
subsequent writes give no output. Also, no errors were reported by the
Sun JVM 1.3, even with -verbose.
When run in the Cygwin shell, the java Application works. The
application continues to write to standard output after the dll is
loaded.
I believe this error is related to the report "Standard streams closed
when g++-produced DLL loaded"
(http://gcc.gnu.org/ml/gcc-prs/2001-07/msg00739.html) which was made
by lerios at cs dot stanford dot edu.
All the relevant files are attached.
Regards,
A.j.
Cygnus Win95/NT Configuration Diagnostics
Current System Time: Sat Oct 13 03:23:38 2001
WinNT Ver 5.0 build 2195 Service Pack 2
Path: /C/DJGPP/BIN
/C/WINNT/system32
/C/WINNT
/C/WINNT/System32/Wbem
/C/Program Files/Dell/Resolution Assistant/Common/bin
/C/jdk1.3/bin
/usr/bin
SysDir: C:\WINNT\System32
WinDir: C:\WINNT
!C: = `C:\JavaWork'
!EXITCODE = `00000000'
ALLUSERSPROFILE = `C:\Documents and Settings\All Users'
APPDATA = `C:\Documents and Settings\Kara Elmquist\Application Data'
CLASSPATH = `.;C:\jdk1.3\lib\tools.jar;C:\Tomcat3.2.3\lib\servlet.jar'
COMMONPROGRAMFILES = `C:\Program Files\Common Files'
COMPUTERNAME = `YT'
COMSPEC = `C:\WINNT\system32\cmd.exe'
DJGPP = `C:\DJGPP\DJGPP.ENV'
HOMEDRIVE = `C:'
HOMEPATH = `\'
JAVA_HOME = `C:\jdk1.3'
LOGONSERVER = `\\YT'
NUMBER_OF_PROCESSORS = `1'
OS = `Windows_NT'
OS2LIBPATH = `C:\WINNT\system32\os2\dll;'
PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
PROCESSOR_ARCHITECTURE = `x86'
PROCESSOR_IDENTIFIER = `x86 Family 6 Model 8 Stepping 6, GenuineIntel'
PROCESSOR_LEVEL = `6'
PROCESSOR_REVISION = `0806'
PROGRAMFILES = `C:\Program Files'
PROMPT = `$P$G'
SYSTEMDRIVE = `C:'
SYSTEMROOT = `C:\WINNT'
TEMP = `/C/DOCUME~1/KARAEL~1/LOCALS~1/Temp'
TMP = `/C/DOCUME~1/KARAEL~1/LOCALS~1/Temp'
TOMCAT_HOME = `C:\Tomcat3.2.3'
USERDOMAIN = `YT'
USERNAME = `Kara Elmquist'
USERPROFILE = `C:\Documents and Settings\Kara Elmquist'
WINDIR = `C:\WINNT'
TERM = `cygwin'
TZ = `PST8PDT7,M4.1.0/2,M10.5.0/2'
HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
(default) = `/cygdrive'
cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/C
(default) = `C:'
flags = 0x00000000
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\Programs\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
(default) = `C:/cygwin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
(default) = `C:/cygwin/bin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
(default) = `C:/cygwin/lib'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options
a: fd FAT 1Mb 11% CP UN
c: hd FAT32 9772Mb 31% CP UN
d: cd N/A N/A
C:\cygwin\bin /usr/bin system binmode
C:\cygwin\lib /usr/lib system binmode
C:\cygwin / system binmode
C: /C user textmode
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cpp.exe
Found: C:\cygwin\bin\find.exe
Found: C:\cygwin\bin\gcc.exe
Found: C:\cygwin\bin\gdb.exe
Found: C:\cygwin\bin\ld.exe
Found: C:\cygwin\bin\ls.exe
Found: C:\cygwin\bin\make.exe
Found: C:\cygwin\bin\sh.exe
701k 2001/10/13 .\cygwin1.dll - os=4.0 img=1.0 sys=4.0
"cygwin1.dll" v0.0 ts=2001/9/12 20:54
Cygwin DLL version info:
dll major: 1003
dll minor: 3
dll epoch: 19
dll bad signal mask: 19005
dll old termios: 5
dll malloc env: 28
api major: 0
api minor: 46
shared data: 3
dll identifier: cygwin1
mount registry: 2
cygnus registry name: Cygnus Solutions
cygwin registry name: Cygwin
program options name: Program Options
cygwin mount registry name: mounts v2
cygdrive flags: cygdrive flags
cygdrive prefix: cygdrive prefix
cygdrive default prefix:
build date: Wed Sep 12 23:54:31 EDT 2001
shared id: cygwin1S3
701k 2001/10/13 .\cygwin1.dll - os=4.0 img=1.0 sys=4.0
"cygwin1.dll" v0.0 ts=2001/9/12 20:54
Cygwin DLL version info:
dll major: 1003
dll minor: 3
dll epoch: 19
dll bad signal mask: 19005
dll old termios: 5
dll malloc env: 28
api major: 0
api minor: 46
shared data: 3
dll identifier: cygwin1
mount registry: 2
cygnus registry name: Cygnus Solutions
cygwin registry name: Cygwin
program options name: Program Options
cygwin mount registry name: mounts v2
cygdrive flags: cygdrive flags
cygdrive prefix: cygdrive prefix
cygdrive default prefix:
build date: Wed Sep 12 23:54:31 EDT 2001
shared id: cygwin1S3
56k 2000/12/03 C:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
"cygbz21.0.dll" v0.0 ts=2000/11/20 15:53
18k 2000/10/23 C:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm.dll" v0.0 ts=2000/10/22 19:26
21k 2001/06/20 C:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
"cygintl.dll" v0.0 ts=2001/6/20 10:09
45k 2001/07/04 C:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
"cygjbig1.dll" v0.0 ts=2001/7/3 20:25
119k 2001/06/06 C:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
"cygjpeg6b.dll" v0.0 ts=2001/6/5 21:27
45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
"cygform5.dll" v0.0 ts=2001/4/24 22:28
26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
"cygmenu5.dll" v0.0 ts=2001/4/24 22:27
156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++5.dll" v0.0 ts=2001/4/24 22:29
226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses5.dll" v0.0 ts=2001/4/24 22:17
15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
"cygpanel5.dll" v0.0 ts=2001/4/24 22:27
34k 2001/09/30 C:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
"cygform6.dll" v0.0 ts=2001/9/29 19:43
19k 2001/09/30 C:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
"cygmenu6.dll" v0.0 ts=2001/9/29 19:43
175k 2001/09/30 C:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++6.dll" v0.0 ts=2001/9/29 19:45
201k 2001/09/30 C:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
"cygncurses6.dll" v0.0 ts=2001/9/29 19:42
12k 2001/09/30 C:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
"cygpanel6.dll" v0.0 ts=2001/9/29 19:43
163k 2001/05/06 C:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
"cygpng2.dll" v0.0 ts=2001/5/5 21:05
17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
"cyghistory4.dll" v0.0 ts=2001/1/6 20:34
21k 2001/06/28 C:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
"cyghistory5.dll" v0.0 ts=2001/6/27 19:27
108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
"cygreadline4.dll" v0.0 ts=2001/1/6 20:34
135k 2001/06/28 C:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0
"cygreadline5.dll" v0.0 ts=2001/6/27 19:27
81k 2000/12/05 C:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
"cygitcl30.dll" v0.0 ts=2000/11/25 17:43
35k 2000/12/05 C:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
"cygitk30.dll" v0.0 ts=2000/11/25 17:43
390k 2000/12/05 C:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
"cygtcl80.dll" v0.0 ts=2000/11/25 17:39
5k 2000/12/05 C:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
10k 2000/12/05 C:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
"cygtclreg80.dll" v0.0 ts=2000/11/25 17:39
623k 2000/12/05 C:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
"cygtk80.dll" v0.0 ts=2000/11/25 17:43
245k 2001/06/12 C:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
"cygtiff3.dll" v0.0 ts=2001/6/12 10:25
41k 2001/07/04 C:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
"cygXpm-noX4.dll" v0.0 ts=2001/7/3 18:21
45k 2001/07/04 C:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
"cygXpm-X4.dll" v0.0 ts=2000/11/19 18:45
49k 2001/02/03 C:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
"cygz.dll" v0.0 ts=2001/2/3 12:35
701k 2001/09/13 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
"cygwin1.dll" v0.0 ts=2001/9/12 20:54
Cygwin DLL version info:
dll major: 1003
dll minor: 3
dll epoch: 19
dll bad signal mask: 19005
dll old termios: 5
dll malloc env: 28
api major: 0
api minor: 46
shared data: 3
dll identifier: cygwin1
mount registry: 2
cygnus registry name: Cygnus Solutions
cygwin registry name: Cygwin
program options name: Program Options
cygwin mount registry name: mounts v2
cygdrive flags: cygdrive flags
cygdrive prefix: cygdrive prefix
cygdrive default prefix:
build date: Wed Sep 12 23:54:31 EDT 2001
shared id: cygwin1S3
Use -h to see help about each section
#
# Sample makefile to create Java JNI with Cygwin b20.1 tools. This *will not*
# work with Cygwin versions earlier than b20.1.
#
# The only difference from creating a regular DLL is to supply a different
# entry point, __cygwin_noncygwin_dll_entry@12, since Java is an MSVC app.
#
# See Makefile.nocyg if you want to use -mno-cygwin and build a Mingw JNI.
#
CC = gcc
CXX = c++
DEBUG = -g -Wall -O2
CXXFLAGS = $(DEBUG)
CFLAGS = $(DEBUG)
CPPFLAGS = -I. -I$(JDK_ROOT)/include -I$(JDK_ROOT)/include/win32
JDK_ROOT = c:/jdk1.3
AS = as
DLLTOOL = dlltool
DLLWRAP = dllwrap
#
# Various targets to build.
#
DLL_NAME = Summation.dll
DLL_EXP_DEF = Summation.def
all: $(DLL_NAME)
#
# DLL related variables. These are used when building the DLL. See later.
#
# Some tools require special CPP macros when building a DLL (eg., _DLL etc).
# Here we don't need anything.
DLL_CFLAGS = -DBUILDING_DLL=1 -D_DLL=1
# The default entry point defined by dllwrap is __cygwin_dll_entry@12
# defined in libcygwin.a, but that's only appropriate for Cygwin apps,
# but since Java is a MSVC app, we need to provide a different entry
# point. Note the leading underscore and the trailing @12.
# The -s flag strips the DLL to shrink the size.
DLL_LDFLAGS = -Wl,-e,__cygwin_noncygwin_dll_entry@12 -s
# any extra libraries that your DLL may depend on.
DLL_LDLIBS =
DLL_SRCS = Summation.cc
DLL_OBJS = $(DLL_SRCS:.cc=.o)
DLL_OBJS := $(DLL_OBJS:.c=.o)
###
#
# Making DLL
#
###
DLLWRAP_FLAGS = --output-def $(DLL_EXP_DEF) \
--add-stdcall-alias \
--driver-name $(CC) \
$(IMAGE_BASE)
$(DLL_NAME): $(DLL_OBJS)
$(DLLWRAP) $(DLLWRAP_FLAGS) -o $(DLL_NAME) \
$(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS)
#
# dependencies.
#
#
# default rules for building DLL objects. Note that client programs (ie.,
# the ones that *use* the DLL) have to be compiled without the DLL_CFLAGS
# flags.
#
.cc.o:
$(CXX) -c $(DLL_CFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
.c.o:
$(CC) -c $(DLL_CFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ $<
# Note that we omit the $(DLL_CFLAGS) for client programs.
usedll.o: %o: %c
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
clean:
-rm -f $(OBJS) $(DLL_OBJS) $(DLL_NAME) $(DLL_EXP_LIB) $(DLL_EXP_DEF) $(TESTPROGS)
// PROGRAM: Summation.c
// PROGRAMMER: Kara Elmquist
// DATE: 2001/10/12
// PURPOSE: Sum integers from 1 to X
#include <jni.h>
#include "Summation.h"
JNIEXPORT jdouble JNICALL Java_Summation_summation_1C
(JNIEnv *env, jobject obj, jlong X)
{
/*Sum integers from 1 to X*/
double i;
double sum;
for(i=1,sum=0; i<=X; i++)
{
sum = sum + i;
}
return sum;
}
; dlltool --base-file /C/DOCUME~1/KARAEL~1/LOCALS~1/Temp/cc001148.base --output-exp Summation.exp --dllname Summation.dll --output-def Summation.def --add-stdcall-alias --exclude-symbol=_cygwin_dll_entry@12 --def /C/DOCUME~1/KARAEL~1/LOCALS~1/Temp/cc001148.def
EXPORTS
Java_Summation_summation_1C = Java_Summation_summation_1C@16 @ 1 ;
Java_Summation_summation_1C@16 @ 2 ;
Summation.dll
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Summation */
#ifndef _Included_Summation
#define _Included_Summation
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: theSummation */
/*
* Class: Summation
* Method: summation_C
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_Summation_summation_1C
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif
// PROGRAM: Summation.java
// PROGRAMMER: Kara Elmquist
// DATE: 2001/10/12
// PURPOSE: Sum integers from 1 to X
public class Summation
{
private static Summation theSummation = new Summation();
public native double summation_C(long X);
public double summation(long X)
{
double i;
double sum;
for(i=1,sum=0; i<=X; i++)
{
sum = sum + i;
}
return sum;
}
public void run(long[] testNumbers)
{
System.out.println("Java Function Results:");
Timer clock = new Timer(); //A timer
for(int i=0;i<testNumbers.length;i++)
{
double sumToNum = testNumbers[i];
//function will sum from 1 to this number
clock.start();
double total = summation(testNumbers[i]);
clock.stop();
System.out.println("Sum from 1 to " + sumToNum + "= " +
total);
System.out.println("Time: " + clock.elapsed() + "secs");
clock.clear();
}
System.out.println("C Function Results:");
for(int i=0;i<testNumbers.length;i++)
{
double sumToNum = testNumbers[i];
//function will sum from 1 to this number
clock.start();
double total = summation_C(testNumbers[i]);
clock.stop();
System.out.println("Sum from 1 to " + sumToNum + "= " +
total);
System.out.println("Time: " + clock.elapsed() + "secs");
clock.clear();
}
}
static
{
System.out.println( "Before load summation\n");
System.loadLibrary("Summation");
System.out.println( "after load Summation\n");
}
public static void main(String[] args)
{
double result;
long[] testNums = {100, 1000, 10000, 100000, 1000000};
System.out.println( "Before run\n");
theSummation.run(testNums);
System.out.println( "Done!\n");
}
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/