esh187
May 20, 2020, 1:19pm
#1
I am confused about where I should start with working on ROOT. I have installed it but I don’t understand how to run macros on it or what the general syntax is supposed to be like. The only coding I have done so far is compile C++ codes for my school projects etc. Any help would be appreciated.

ROOT Version: 6.18
Platform: Windows 10

esh187
May 20, 2020, 2:06pm
#3
So I used this code word for word

```
root [6] double x=.5
(double) 0.500000
root [7] int N=30
(int) 30
root [8] double geom_series=0
(double) 0.000000
root [9] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [10] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
```

and this was the output I got:

```
ROOT_prompt_6:1:9: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
^~~~~~~~~~
ROOT_prompt_6:1:37: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
^~~~~~~~~~~~
input_line_200:2:3: error: use of undeclared identifier 'cout'
(cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
^
input_line_200:2:18: error: expected unqualified-id
(cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
^
input_line_200:2:40: error: expected '(' for function-style cast or type construction
(cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
~~~~~~~~^
input_line_200:2:42: error: expected expression
(cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
^
input_line_200:2:94: error: expected unqualified-id
(cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
^
input_line_200:2:116: error: expected '(' for function-style cast or type construction
...TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t...
~~~~~~~~^
input_line_200:2:118: error: unexpected type name 'Int_t': expected expression
...(Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t)*)0x155bb0c0))(((*(...
^
input_line_200:2:125: error: expected expression
...(Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t)*)0x155bb0c0))(((*(...
^
input_line_200:2:227: error: use of undeclared identifier 'endl'
...((*(int*)0x1280038)) - 1)) / (1 - ((*(double*)0x1280030)))) << endl)
```

I don’t understand what’s wrong

Hi @esh187 ,
that snippet works fine on linux, so I guess the problem is with windows (@bellenot might have an idea about the precise cause).

How did you install ROOT on windows? There is a number of features that does not work there, as far as I know.

Cheers,
Enrico

couet
May 20, 2020, 2:50pm
#5
It is fine on Mac too:

```
root [6] double x=.5
(double) 0.50000000
root [7] int N=30
(int) 30
root [8] double geom_series=0
(double) 0.0000000
root [9] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [10] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
1.86265e-09
root [11]
```

Weird, it works also for me:

```
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.0
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'
C:\Users\bellenot>cd temp
C:\Users\bellenot\temp>root\bin\thisroot.bat
C:\Users\bellenot\temp>root -l
root [0] double x=.5
(double) 0.50000000
root [1] int N=30
(int) 30
root [2] double geom_series=0
(double) 0.00000000
root [3] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [4] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
1.86265e-09
root [5]
```

But it might still come from an incompatibility of different versions of Visual Studio (I tried with ROOT v6.18/04). I’m checking right now

esh187:

root [6] double x=.5

What did you do before in ROOT (i.e. the first five lines/commands)? Can you try to start again from a clean prompt and type only the lines you posted here?

esh187
May 21, 2020, 11:45am
#8
root [0] double x=.5
(double) 0.50000000
root [1] int N=30
(int) 30
root [2] double geom_series = 0
(double) 0.00000000
root [3] for( int i=0; i<N ; ++i)geom_series+= TMath::Power(x,i)
root [4] cout<< TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
ROOT_prompt_4:1:8: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout<< TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
^~~~~~~~~~
ROOT_prompt_4:1:36: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout<< TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
^~~~~~~~~~~~
input_line_14:2:3: error: use of undeclared identifier ‘cout’
(cout << TMath::(((Double_t (Double_t) )0xade5070))((((double )0xae00030)) - (1 - TMath::(((Double_t (Double…
^
input_line_14:2:18: error: expected unqualified-id
(cout << TMath::(( (Double_t (Double_t))0xade5070))((( (double*)0xae00030)) - (1 - TMath::(((Double_t (Double…
^
input_line_14:2:40: error: expected ‘(’ for function-style cast or type construction
(cout << TMath::(( (Double_t (Double_t))0xade5070))((( (double*)0xae00030)) - (1 - TMath::((*(Double_t (Double…
~~~~~~~~^
input_line_14:2:42: error: expected expression
(cout << TMath::(((Double_t (Double_t) )0xade5070))((((double )0xae00030)) - (1 - TMath::(((Double_t (Double…
^
input_line_14:2:93: error: expected unqualified-id
(cout << TMath::(( (Double_t (Double_t))0xade5070))((( (double*)0xae00030)) - (1 - TMath::(((Double_t (Double…
^
input_line_14:2:115: error: expected ‘(’ for function-style cast or type construction
…TMath::(( (Double_t (Double_t))0xade5070))((( (double*)0xae00030)) - (1 - TMath::(((Double_t (Double_t, Int_t)…
~~~~~~~~^
input_line_14:2:117: error: unexpected type name ‘Int_t’: expected expression
…(Double_t) )0xade5070))((((double )0xae00030)) - (1 - TMath::(((Double_t (Double_t, Int_t) )0xade50c0))((((do…
^
input_line_14:2:124: error: expected expression
…(Double_t) )0xade5070))((((double )0xae00030)) - (1 - TMath::(((Double_t (Double_t, Int_t) )0xade50c0))((((do…
^
input_line_14:2:225: error: use of undeclared identifier ‘endl’
…(( (int*)0xae00028)) - 1)) / (1 - (((double )0xae00020)))) << endl)

And then it simply exits the ROOT session and I’m back where I started. Maybe I didn’t install it right?

Try with: `std::cout << ... << std::endl;`

or start with `#include <iostream>`

esh187
May 21, 2020, 11:54am
#11
Did this and this time the result was:
ROOT_prompt_5:1:35: error: expression is not assignable
cout<< TMath::Abs(geom_series - (1–TMath::Power(x,N-1))/(1-x)) << endl;
~^
ROOT_prompt_5:1:68: error: use of undeclared identifier ‘endl’
cout<< TMath::Abs(geom_series - (1–TMath::Power(x,N-1))/(1-x)) << endl;
^
root [6]

esh187
May 21, 2020, 11:55am
#12
error: expression is not assignable
This is what I got.

esh187
May 21, 2020, 11:56am
#13
I have verison v6.18/04 downloaded on my Windows10 with Visual Studio 2019 at the moment. Maybe I should install an earlier version @bellenot ?

can you try to use another variable name than `geom_series`

?

esh187
May 21, 2020, 12:09pm
#16
Did that, stills shows errors. Maybe it has something to do with the way I installed or something?

esh187
May 21, 2020, 12:12pm
#17
Any particular thing I need to know about the Folders and such in which I have installed the root version v6.18/04?

The only restriction is to install it in a path not containing any white space. Why? where did you install it?

esh187
May 21, 2020, 12:19pm
#19
No there is no white space or anything of the sort in the path. It won’t even accept " cout " and “endl” for some reason and I don’t understand why that is

Which version of Visual Studio 2019 do you have?