RE: Visual Studio Example Needed

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Thu, 10 Aug 2006 16:32:39 +0200


Hi Weijun,

On Thu, 2006-08-10 at 07:17 -0500, Weijun Guo wrote:
> Hi, Valeriy,
>
> I have the test files on my root package as well. I tried the following
> two options with no success:

I'm only commenting on Cygwin, as I have little experience with the MSVC-ROOT combo.

> 1. using cygwin make facility.

Which ROOT did you use for that? The GCC compiled, or the MSVC compiled version. They are separate downloads from the ROOT web-pages.

If you're using the GCC compiled version, the Makefile should look like any other standard Makefile for a POSIX system:

        CPPFLAGS	= -I$(shell root-config --incdir)
        CPP		= g++ -E
        CXXFLAGS	= 
        CXX		= g++ -c 
        LDFLAGS		= -L$(shell root-config --libdir)
        LD		= g++ 
        SOFLAGS		=
        SO		= g++ -shared 
        ROOTCINT	= $(shell root-config --bindir)/rootcint 
        
        %.o:%.cxx
        	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< 
        
        %.so:%.o %Dict.o
        	$(SO) $(SOFLAGS) -o $@ $^ 
        
        %Dict.h:%Dict.cxx
        	@if test -f $@ ; then : ; else rm -f $< ; $(MAKE) $< ; fi
        
        %Dict.cxx:%.h
        	$(ROOTCINT) -f $@ -c $(CPPFLAGS) $^ 
        
        all:	Foo.so
        clean:	
        	rm -f Foo.so Foo.o FooDict.o FooDict.cxx FooDict.h

If you're using the MSCV, the compiler is called `CL.EXE'. First of all, make sure that that program is in the path of your Cygwin shell. Usually, it lives in something like

        c:\Program Files\Microsoft Visual Studio\VC98\Bin
        

so you should add that directory to the PATH evironment variable. Do something like

        export PATH=${PATH}:`cygpath -u 'c:\\Program\ Files\\Microsoft\ Visual\ Studio\\VC98\\bin'`
        

Similarly, you should make sure that the INC and LIB environment variables are set correctly in the Cygwin shell. Also make sure that the path to ROOT is in the PATH environment variable. Usually it's something like

        export ROOTSYS=`cygpath -u c:\\root`
        export PATH=${PATH}:${ROOTSYS}/bin
        

Now, the compiler `CL.EXE' does not accept the same command line options as GCC (or any other Un*x compiler for that matter), so the Makefile needs to be a little different. To complicate things even further, the act of making a DLL requires some additional information - namely what symbols to export. So a Makefile could look like

        INC_PATH		= $(shell root-config --incdir);$(INC)
        LIB_PATH		= $(shell root-config --libdir);$(LIB)
        CXX			= CL.EXE /C
        CXXFLAGS		= /GX
        SO			= CL.EXE /DLL
        SOFLAGS			=
        
        %.obj:%.cxx
        	INC=$(INC_PATH) $(CXX) $(CXXFLAGS) $< 
        
        %.dll:%.o %Dict.o
        	$(SO) $(SOFLAGS) -o $@ $^ 
        
        %Dict.h:%Dict.cxx
        	@if test -f $@ ; then : ; else rm -f $< ; $(MAKE) $< ; fi
        
        %Dict.cxx:%.h
        	$(ROOTCINT) -f $@ -c $(CPPFLAGS) $^ 
        
        all:	Foo.dll
        clean:	
        	rm -f Foo.dll Foo.obj FooDict.obj FooDict.cxx FooDict.h

Note, that I haven't tried this, so you may need to adjust it a bit. 
        

My suggestion would be to use the GCC compiled ROOT.

Yours,

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Thu Aug 10 2006 - 16:33:43 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:00 MET