Root and VC++2008 Express Edition

Hi, Everybody

I’m a very beginner in Root and I have trouble with it (Root version 5.27/04; XP; Microsoft Visual C++ Express Edition 2008).
I want to run this code:

[b]#include “TH1F.h”
#include “TPad.h”
#include “TROOT.h”

void DrawGaussian()
{
TH1F* h=(TH1F*)gROOT->FindObject(“h_gaus”);
if( h ){
h->Reset();
} else {
h = new TH1F(“h_gaus”,“Une gaussienne”,100,0.,100.);
}
h->Draw();
for(Double_t x=0; x<100; x++)
{
Double_t f = 20.*exp( -pow(x-50.,2)/2./pow(10,2) );
h->Fill(x,f);
gPad->Modified(); gPad->Update();
}
}[/b]

When trying,

root [0] .L fillHisto.C+

I have the error message below:

Info in TWinNTSystem::ACLiC: creating shared library C:\root\macros\fillHisto_
C.dll
’cl.exe’ n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Error: external preprocessing failed. (0)
!!!Removing C:\root\macros\fillHisto_C_ACLiC_dict.cxx C:\root\macros\fillHisto_C
_ACLiC_dict.h !!!
Error: C:\root\bin\rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity

What should I do? PATH is on (C:\root\bin); ROOTSYS on (C:\root)

Thanks for your help.

Chesco

Hi,

The environment variables have to be set for Visual C++. You have to start root from a Visual Studio 2008 command prompt (accessible from the Windows main menu) or to start “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat” from your command prompt before to start root.exe in order to be able to use ACLiC

Cheers, Bertrand.

[quote=“bellenot”]Hi,

The environment variables have to be set for Visual C++. You have to start root from a Visual Studio 2008 command prompt (accessible from the Windows main menu) or to start “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat” from your command prompt before to start root.exe in order to be able to use ACLiC

Cheers, Bertrand.[/quote]

Hi Bertrand,

Thank you for your help,
I 've tried to start “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat” from my command prompt before to start root.exe, but I’ve always the same error.

Info in TWinNTSystem::ACLiC: creating shared library C:\root\macros\fillHisto_
C.dll
’cl.exe’ n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Error: external preprocessing failed. (0)
!!!Removing C:\root\macros\fillHisto_C_ACLiC_dict.cxx C:\root\macros\fillHisto_C
_ACLiC_dict.h !!!
Error: C:\root\bin\rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity

Thanks you (Merci, I speak french),

Chesco

Hi Chesco,

I speak french too, but let’s speak english for the rest of the world :wink:
You should see something like this:

C:\Users\bellenot>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsa
ll.bat"
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Users\bellenot>

Otherwise something went wrong (check your path to make sure vcvarsall.bat is there…). Then you should be able to type cl and get something like:

[code]c:\Users\bellenot>cl
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright © Microsoft Corporation. All rights reserved.

usage: cl [ option… ] filename… [ /link linkoption… ]

c:\Users\bellenot>[/code]
Cheers, Bertrand.

[quote=“bellenot”]Hi Chesco,

I speak french too, but let’s speak english for the rest of the world :wink:
You should see something like this:

C:\Users\bellenot>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsa
ll.bat"
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Users\bellenot>

Otherwise something went wrong (check your path to make sure vcvarsall.bat is there…). Then you should be able to type cl and get something like:

[code]c:\Users\bellenot>cl
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright © Microsoft Corporation. All rights reserved.

usage: cl [ option… ] filename… [ /link linkoption… ]

c:\Users\bellenot>[/code]
Cheers, Bertrand.[/quote]
Hi Bertrand,
Thanks for your answers.
I tried your procedure but the problem remains.
As you told me, before to run root, I’ve started vcvarsall.bat from my command prompt before to start root:

[b]Microsoft Windows XP [version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\admin>"C:\Program Files\Microsoft Visual Studio 9.0\VC
\vcvarsall.bat"
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Documents and Settings\admin>cl
Compilateur d’optimisation Microsoft ® 32 bits C/C++ version 15.00.21022.08 po
ur 80x86
Copyright © Microsoft Corporation. Tous droits réservés.

utilisation : cl [ option… ] nom de fichier… [ /link linkoption… ]

C:\Documents and Settings\admin>[/b]

After this, I performed Root :

root [0] .L fillHisto1.C+
Info in TWinNTSystem::ACLiC: creating shared library C:\root\macros\fillHisto1
_C.dll
’cl.exe’ n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Error: external preprocessing failed. (0)
!!!Removing C:\root\macros\fillHisto1_C_ACLiC_dict.cxx C:\root\macros\fillHisto1
_C_ACLiC_dict.h !!!
Error: C:\root\bin\rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
root [1]

Am I wrong?
Sorry to ask so many questions! I am really a beginner with Root! :blush:
Thank you.

Chesco

Hi Chesco,

That’s very weird… One more thing: you have to call “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat” from the same command prompt from where you start root (the variables are set locally)
I ask since I see you call vcvarsall.bat from C:\Documents and Settings\admin and then I see the root session in
C:\root\macros…
You sould be able to call cl directly from within a root session, it should work:

[code]c:\Users\bellenot\root\tutorials\gui>root -l
root [0] .!cl
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright © Microsoft Corporation. All rights reserved.

usage: cl [ option… ] filename… [ /link linkoption… ]
root [1][/code]
Cheers, Bertrand.

[quote=“bellenot”]Hi Chesco,

That’s very weird… One more thing: you have to call “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat” from the same command prompt from where you start root (the variables are set locally)
I ask since I see you call vcvarsall.bat from C:\Documents and Settings\admin and then I see the root session in
C:\root\macros…
You sould be able to call cl directly from within a root session, it should work:

[code]c:\Users\bellenot\root\tutorials\gui>root -l
root [0] .!cl
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright © Microsoft Corporation. All rights reserved.

usage: cl [ option… ] filename… [ /link linkoption… ]
root [1][/code]
Cheers, Bertrand.[/quote]
Hi Bertrand,

Thanks a lot, now it’s ok!! :smiley:

Cheers, Chesco