RE: Visual Studio Example Needed

From: Bertrand Bellenot <Bertrand.Bellenot_at_cern.ch>
Date: Fri, 11 Aug 2006 08:40:18 +0200


Hi Weijun,  

Yes, you have to specify which libraries you want to link with your application.

Cheers,
Bertrand.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch
[mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Weijun Guo Sent: Thursday, August 10, 2006 10:14 PM To: roottalk (Mailing list discussing all aspects of the ROOT system) Subject: RE: [ROOT] Visual Studio Example Needed

Greetings,

It appears that I have to go to "Project Properties" to manually add in those related libraries even after I specified "C:\root\lib" as one of the "Library files" directories? Could someone possibly either correct me or confirm this?

Thanks,

Weijun

-----Original Message-----
From: Weijun Guo
Sent: Thursday, August 10, 2006 2:37 PM
To: 'Christian Holm Christensen'
Cc: Valeri Onuchin; Bertrand Bellenot; roottalk (Mailing list discussing all aspects of the ROOT system)
Subject: RE: [ROOT] Visual Studio Example Needed

Dear Rooters,

I installed VC++7.0 on my PC. It is doing a much better job than Visual Studio 6.0 did.

For those test codes that Valeri referred, most of them were able to compile and run. Except some dict files were missing. Probably I needed to use cint to generate them but I do not know how yet? This did not prevent the codes from running though.

For the hello world example that Bertrand sent to me, I was able to open the project file by modifying the version number from 7.1 to 7.0. I should probably update my compiler to .net 2003 or above later. However, this cheating scheme seems to be working for now.

I am planning to try Chris's directions a little later.

Thanks a lot for your warm help. Glad to join root community!

Best regards,

Weijun

-----Original Message-----
From: Christian Holm Christensen [mailto:cholm_at_nbi.dk] Sent: Thursday, August 10, 2006 9:33 AM
To: Weijun Guo
Cc: Valeri Onuchin; Bertrand Bellenot; roottalk (Mailing list discussing all aspects of the ROOT system)
Subject: RE: [ROOT] Visual Studio Example Needed

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
 | |

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and
privileged information for the sole use of the intended recipient.  Any
review, use, distribution, or disclosure by others is strictly
prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the
sender by reply e-mail and delete all copies of this message.
Received on Fri Aug 11 2006 - 08:40:40 MEST

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