RE:streams with CInt

Valery Fine (fine@mail.cern.ch)
Thu, 23 Oct 1997 10:00:44 +0100


Hello William
On 22 Oct 97 at 18:59, you wrote:

> Ooops, one more thing..
>
> root[0] Simple s;
>
> (crash!!!)
>
> I hope someone has more fun with this than I have. :)
> William Deninger
>

Sorry I was ENABLE to reproduce your problem. NO crash !!!

I took your Simple.h and Simple.cxx and made Simple.DLL. I
edited (customized) and applied test/Makefile for that but instead of
Event.cxx, Event.h the Simple's ones were used. The Linkdef.h was
like this

Linkdef.h
====================
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class Simple;

#endif
====================

and Makefile itself follows (see below).

Then I got:

=========== Creating Simple Dictionary and Simnple.DLL :

D:\Users\brun\root\test>nmake -f makefile.simple

Microsoft (R) Program Maintenance Utility Version 1.61.6038
Copyright (C) Microsoft Corp 1988-1996. All rights reserved.

cl -DWIN32 -D_WIN32 -D_MT -D_DLL /Zd /O2 /G5 /MD -D_WINDOWS -I\users\ro
ot\ms/include -c Simple.cxx
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 10.20.6166 for 80x86
Copyright (C) Microsoft Corp 1984-1996. All rights reserved.

Simple.cxx
"Generating dictionary ..."
Note: operator new() masked c
Note: operator delete() masked c
cl -DWIN32 -D_WIN32 -D_MT -D_DLL /Zd /O2 /G5 /MD -D_WINDOWS -I\users\ro
ot\ms/include -c SimpleCint.cxx
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 10.20.6166 for 80x86
Copyright (C) Microsoft Corp 1984-1996. All rights reserved.

SimpleCint.cxx
BINDEXPLIB Simple Simple.obj SimpleCint.obj > Simple.def
lib /nologo /MACHINE:IX86 Simple.obj SimpleCint.obj /def:Simple.def /out
:Simple.lib
Creating library Simple.lib and object Simple.exp
link /NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO -align:0x1
000 -entry:_DllMainCRTStartup@12 -dll Simple.obj SimpleCint.obj Simple.exp \user
s\root\ms/lib/*.lib msvcrt.lib oldnames.lib kernel32.lib advapi32.lib user32.li
b gdi32.lib comdlg32.lib winspool.lib MSVCIRT.LIB /out:Simple.dll
"SIMPLE.dll done"

===========

Then I launched ROOT session:

I:\Users\brun\root\test>root
the current keyboard layout is 866
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 1.03/03 10 September 1997 *
* Development version *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************

CINT/ROOT C/C++ Interpreter version 5.13.24, Aug 24 1997
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gSystem.Load("Simple.DLL")
(int)0
root [1] Simple s;
root [2] .q

I:\Users\brun\root\test>dir test.txt
Volume in drive I is 8Gb
Volume Serial Number is E4B0-CA2D

Directory of I:\Users\brun\root\test

23.10.97 09:54 8 test.txt
1 File(s) 8 bytes
5'483'872'256 bytes free

I:\Users\brun\root\test>type test.txt
3.1415

=========================================================

The ONLY difference my compiler is MSVC v.4.2 and MS did
something with very stream classes. I'd like to pay your attention
that that Simple.DLL as well as ROOT's DLL wre linked against of
MSVCIRT.LIB. This library does contain the implementations of the
"stream" classes. I wonder your problem here ?

# ================================== Begin Of Makefile ==========================
ObjSuf = obj
SrcSuf = cxx
ExeSuf = .exe
DllSuf = dll
OutPutOpt = /out:

# Win32 system with Microsoft Visual C/C++
!include <win32.mak>
CC = $(cc)
CXX = $(cc)
CXXFLAGS = $(cvarsdll) /Zd /O2 /G5 /MD -D_WINDOWS -I$(ROOTSYS)/include
LD = $(link)
LDFLAGS = $(conlflags)
SOFLAGS = $(dlllflags)
ROOTLIBS = $(ROOTSYS)/lib/*.lib
LIBS = $(ROOTLIBS) $(guilibsdll) MSVCIRT.LIB
LIBSALL = $(ROOTLIBS)
SIMPLELIB = Simple.lib

#------------------------------------------------------------------------------

SIMPLEO = Simple.$(ObjSuf) SimpleCint.$(ObjSuf)

# SIMPLEO = Simple.$(ObjSuf)

SIMPLES = Simple.$(SrcSuf) SimpleCint.$(SrcSuf)

SIMPLESO = libSimple.$(DllSuf)

OBJS = $(SIMPLEO)

PROGRAMS = $(SIMPLE)

DLLS = $(SIMPLESO)

all: $(DLLS) $(PROGRAMS)

$(SIMPLESO): $(SIMPLEO)
BINDEXPLIB Simple $(SIMPLEO) > Simple.def
lib /nologo /MACHINE:IX86 $(SIMPLEO) /def:Simple.def $(OutPutOpt)$(SIMPLELIB)
$(LD) $(SOFLAGS) $(SIMPLEO) Simple.exp $(LIBS) $(OutPutOpt)Simple.dll
@echo "SIMPLE.dll done"

clean:
@del /q $(OBJS) SimpleCint.$(SrcSuf) SimpleCint.h

###

SimpleCint.$(SrcSuf): Simple.h LinkDef.h
@echo "Generating dictionary ..."
@rootcint -f SimpleCint.$(SrcSuf) -c Simple.h LinkDef.h

.$(SrcSuf).$(ObjSuf):
$(CXX) $(CXXFLAGS) -c $<
# ================================== End Of Makefile ==========================
Dr. Valeri Faine (Valery Fine)
------------ ------------- Phone: +41 22 767 4921
CERN FAX : +41 22 767 7155
CH-1211 Geneva, 23 mailto:fine@mail.cern.ch
Switzerland http://nicewww.cern.ch/~fine