Re: Root in Visual C++

From: Valery Fine (fine@bnl.gov)
Date: Tue Sep 08 1998 - 18:09:43 MEST


Dear GENTIT Francois-Xavier  DAPNI
On  8 Sep 98 at 16:09,  you wrote:

> 
>     Recently I got a PC and was happy by the idea of working with
>     ROOT
> on PC having a machine for me alone. Unfortunatly, I did not succeed
> 100%. First this is what I succeed in :
> 
>    (1) - installation of ROOT on the PC.
>    (2) - installation of my code under Visual C++ with a makefile. I
> could compile my code, link it with the ROOT libraries and execute
> it ok.
> 
> This is what went wrong :
> 
>     I had the surprise to discover that Visual C++ disables the
>     debugger
> when one enter in Visual C++ with a makefile ( which is a
> non-standard way of using Visual C++ ).

  I am very sorry but I didn't under what did mean "disables" 
debugger.

  One can connect the VC++ debugger to any running process even 
"on fly" via 

     "Build" -> "Start Debug" ->  "Attach to Process" 

  Developer studio menu.

> So I tried to make, very painfully, a "developer studio project". 

 One doesn't need any "developer studio project" to use VC++ debugger 
(see above)

> I had to find which were the libraries behind the "guilibsdll", how to indicate to Visual C++
> where to find the include files, and so on. 

  Usually all system libraires are supplied by Studio, so one is not 
required to figure this out on his own. The system libraries are 
defined with the project type

> I never succeed in linking my code that way. I give at the end of this message the kind
> of error messages I get, but I think it is much too complicate to
> try to solve this kind of problem by mail, so the aim of this mail
> is to kindly ask the Authors of ROOT to provide on the web some
> documentation about the use of ROOT in Visual C++. 

  The directory test contains Makefile but it doesn't generate the 
debug information.

 I'll try to correct it to provide this information.

  Meantime I am forwarding you another makefile.
  This makefile is used to generate C++ class for STAR experiment at BNL 

  http://www.rhic.bnl.gov/STAR/html/comp_l/train/root/Star2C++tut.html

   and it does provide us a debug information

Makefile:
---------

ObjSuf        = obj
SrcSuf        = cxx
ExeSuf        = .exe
DllSuf        = dll
OutPutOpt     = /out:
RM             = del /q

PAMSM         = tpc
PAMS          = pamc

# Win32 system with Microsoft Visual C/C++
!include <win32.mak>
CC            = $(cc)
CXX           = $(cc)
STAR_INCLUDE  = /I$(STAR)/asps/staf/inc  ....  /I$(AFS_RHIC)\asis\share\cern\new\include 
CXXFLAGS      = $(cvarsdll) /Zi /Fd$(PDB) /G5 /MD -D_WINDOWS -I$(ROOTSYS)/include $(STAR_INCLUDE) 
LD            = $(lin LDFLAGS       = $(conlflags) # 
SOFLAGS       = /DEBUG $(dlllflags) /PDB:$(PDB)_all 
SOFLAGS       = /DEBUG /NODEFAULTLIB /INCREMENTAL:NO /NOLOGO /DLL /PDB:$(PDB)_all 
ROOTLIBS      = $(ROOTSYS)/lib/*.lib 
LIBS          = $(ROOTLIBS) $(guilibsdll) $(LIB_STAR)\dsl.lib MSVCIRT.LIB 
LIBSALL       = $(ROOTLIBS) STMODULELIB   = St_base.lib 
PDB           = St_base



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

STMODULEO     = St_Module.$(ObjSuf) St_Table.$(ObjSuf) St_DataSet.$(ObjSuf) St_FileSet.$(ObjSuf) St_XDFFile.$(ObjSuf)\
                St_ModuleCint.$(ObjSuf)

STMODULES     = St_Module.$(SrcSuf) St_Table.$(SrcSuf) St_DataSet.$(SrcSuf) St_FileSet.$(SrcSuf) St_XDFFile.$(SrcSuf)\
                St_ModuleCint.$(SrcSuf)

MAINSTMODULES = MainSt_Module.$(SrcSuf)

MAINSTMODULEO = MainSt_Module.$(ObjSuf)

STMODULE      = St_base$(ExeSuf)
STMODULESO    = libSt_Module.$(DllSuf)


OBJS          = $(STMODULEO)

PROGRAMS      = $(STMODULE)

#  $(MAINSTMODULEO)

all:            $(PROGRAMS)


$(STMODULE):    $(STMODULEO)
                BINDEXPLIB  St_base $(STMODULEO) > St_base.def
                lib /nologo /MACHINE:IX86 $(STMODULEO) /def:St_base.def $(OutPutOpt)$(STMODULELIB)
                $(LD) $(SOFLAGS) $(STMODULEO) St_base.exp $(LIBS)       $(OutPutOpt)St_base.dll
                @echo "St_base.dll done"

clean:
                @$(RM) $(OBJS) St_ModuleCint.$(SrcSuf) St_ModuleCint.h *.pdb

###

St_Module.obj: St_Module.cxx St_Module.h

St_Table.obj: St_Table.cxx St_Table.h St_DataSet.h

St_DataSet.obj: St_DataSet.cxx St_DataSet.h

St_FileSet.obj: St_FileSet.cxx St_FileSet.h St_DataSet.h

St_XDFFile.obj: St_XDFFile.cxx St_XDFFile.h St_DataSet.h St_Table.h

LinkDef.h:
       @echo #ifdef __CINT__ >LinkDef.h
       @echo #pragma link off all globals;>>LinkDef.h
       @echo #pragma link off all classes;>>LinkDef.h
       @echo #pragma link off all functions;>>LinkDef.h
       @echo #pragma link C++ class St_Module-;>>LinkDef.h
       @echo #pragma link C++ class St_Table-;>>LinkDef.h
       @echo #pragma link C++ class St_DataSet;>>LinkDef.h
       @echo #pragma link C++ class St_FileSet;>>LinkDef.h
       @echo #pragma link C++ class St_DataSetIter;>>LinkDef.h
       @echo #pragma link C++ class St_XDFFile;>>LinkDef.h
       @echo #pragma link C++ class table_head_st-!;>>LinkDef.h
       @echo #pragma link C++ enum EModuleTypes;>>LinkDef.h
       @echo #endif>>LinkDef.h

St_ModuleCint.$(SrcSuf): St_Module.h St_Table.h St_DataSet.h St_XDFFile.h St_FileSet.h Makefile 
        @echo "Generating dictionary ..."
        @echo #ifdef __CINT__ >LinkDef.h
        @echo #pragma link off all globals;>>LinkDef.h
        @echo #pragma link off all classes;>>LinkDef.h
        @echo #pragma link off all functions;>>LinkDef.h
        @echo #pragma link C++ class St_Module-;>>LinkDef.h
        @echo #pragma link C++ class St_Table-;>>LinkDef.h
        @echo #pragma link C++ class St_DataSet;>>LinkDef.h
        @echo #pragma link C++ class St_DataSetIter;>>LinkDef.h
        @echo #pragma link C++ class St_FileSet;>>LinkDef.h
        @echo #pragma link C++ class St_XDFFile;>>LinkDef.h
        @echo #pragma link C++ class table_head_st-!;>>LinkDef.h
        @echo #pragma link C++ enum EModuleTypes;>>LinkDef.h
        @echo #endif>>LinkDef.h
        type LinkDef.h
        @rootcint -f St_ModuleCint.$(SrcSuf) -c -DROOT_CINT -I$(STAR_SRC)\SL98b\inc table_header.h St_Module.h St_Table.h St_DataSet.h St_XDFFile.h St_FileSet.h LinkDef.h

.$(SrcSuf).$(ObjSuf):
        $(CXX) $(CXXFLAGS) -c $<

> For me the use of
> a debugger is essential and I return to unix on HP, where the
> debugger dde is working quite well, until I know how to get the
> debugger of Visual C++ to work.

 I'd like to call your attention that there are three (at least) 
sources of the information:

   -  documentation been supplied with your version Visual C++
   -  On line documentaion.
   -  http://www.microsoft.com/kb  (MS knowledge base)


> 
> 
>    This is the kind of error messages I get when trying to link my
>    code
> in a true "developer studio project" in Visual C++ : 
> 
> 
>    messages if one take as libraries :
> 
>       msvcrt.lib oldnames.lib kernel32.lib ws2_32.lib mswsock.lib
> advapi32.lib \
>       user32.lib gdi32.lib comdlg32.lib winspool.lib msvcirt.lib
> 
> 

  Since I didn't see your project it is quite complicate to say what 
you did wrong. 

  I would advice first try to use the Makefile above (and Makefile 
file from the ROOT test subdirectory and that supplied with ATLFAST 
package http://root.cern.ch/root/Atlfast.html as well)

 I hope it helps,
    With my regards,
                        Valery
=================================================================
Dr. Valeri Faine (Fine)
    -------------------          Phone: +1 516 344 7806
Brookhaven National Laboratory   FAX  : +1 516 344 4206
Bldg. 510A /STAR                 mailto:fine@bnl.gov
Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
USA
                                 
Dr. Valery Fine                  Telex : 911621 dubna su
    -----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
Russia                           mailto:fine@main1.jinr.dubna.su                              



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET