# Linking \[cling interface function\]

**URL:** <https://root-forum.cern.ch/t/linking-cling-interface-function/45765>\
**Category:** ROOT\
**Tags:** cling\
**Created:** [July 9, 2021, 10:56am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765 "2021-07-09T10:56:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mai1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mai1](https://root-forum.cern.ch/u/mai1)\
**Post date:** [July 9, 2021, 10:56am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/1 "2021-07-09T10:56:37Z")

</div>

I’m not good at English, so I’m sorry if the sentences are strange.  
I got an error when I tried to execute the following source code.

```cpp
 {
   int n=100;
   double b[10];
   double pi;
double cnt = 0.0;
 double sum=0;
 gRandom->SetSeed();
 for(int a=0.0;a<n;a++){
   double N=1000.0*(a+1.0);
   for (int j=0;j<10.0;j++){
 for (int i = 0.0; i < N; i++) {
   double x = gRandom->Rndm();
   double y = gRandom->Rndm();

		if ((x * x + y * y) < 1.0) {
			cnt +=1.0;
		}
	}
 pi = 4.0*cnt/N;
 sum+=pi;
 b[j]=pi;
   }
   double mean=pi/10;
   double sum11 = 0.0000;
   for (int j = 0; j < 10; i++)sum11 += (b[j] - mean)*(b[j]-mean);

   double sd = sqrt(sum11 / (10 - 1) / 10);

   	TGraphErrors* g = new TGraphErrors;
        g->SetPointError(a, 0, sd);  
	g->SetPoint(a, N, mean);

	g->SetMarkerStyle(20);
	g->Draw("AP");
 }

return 0;
}

```

I got the following error when using this source code.  
`IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime8internal9EvaluateTIvEET_PNS1_15DynamicExprInfoEPN5clang11DeclContextE' unresolved while linking [cling interface function]!`  
`You are probably missing the definition of void cling::runtime::internal::EvaluateT<void>(cling::runtime::internal::DynamicExprInfo*, clang::DeclContext*)`  
Maybe you need to load the corresponding shared library?

Why do I get such an error?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 9, 2021, 11:17am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/2 "2021-07-09T11:17:38Z")

</div>

At least:  
`for (int j = 0; j < 10; j++) sum11 += (b[j] - mean)*(b[j]-mean);`

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 9, 2021, 11:27am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/3 "2021-07-09T11:27:27Z")

</div>

I have reindent you macro and it looks as follow:

```auto
{
   int n=100;
   double b[10];
   double pi;
   double cnt = 0.0;
   double sum=0;
   int j,i;
   gRandom->SetSeed();
   for(int a=0; a<n; a++){
      double N=1000.0*(a+1.0);
      for (j=0; j<10; j++) {
         for (i=0; i<(int)N; i++) {
            double x = gRandom->Rndm();
            double y = gRandom->Rndm();
            if ((x * x + y * y) < 1.0) cnt +=1.0;
         }
         pi = 4.0*cnt/N;
         sum+=pi;
         b[j]=pi;
      }
      double mean=pi/10;
      double sum11 = 0.0000;
      for (j = 0; j < 10; i++) sum11 += (b[j] - mean)*(b[j]-mean);

      double sd = sqrt(sum11 / (10 - 1) / 10);

      TGraphErrors* g = new TGraphErrors;
      g->SetPointError(a, 0, sd);
      g->SetPoint(a, N, mean);

      g->SetMarkerStyle(20);
      g->Draw("AP");
   }
}

```

I get no error but it seems to be in some endless loop.

---

<div class="post-metadata">

**Author:** ![mai1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mai1](https://root-forum.cern.ch/u/mai1)\
**Post date:** [July 9, 2021, 11:37am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/4 "2021-07-09T11:37:12Z")

</div>

It was a rudimentary mistake. I feel bad. I got another error when I corrected the pointed out part. I’m assuming you should see 200 plots on the graph, but only one.  
If you have time, I would appreciate it if you could reply.

Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1

---

<div class="post-metadata">

**Author:** ![mai1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mai1](https://root-forum.cern.ch/u/mai1)\
**Post date:** [July 9, 2021, 11:46am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/5 "2021-07-09T11:46:27Z")

</div>

Thank you!  
There was no error with this.  
However, the expected graph displayed 100 points with errors, but only one point is displayed. I should have looped 100 times with the for loop, why?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 9, 2021, 11:50am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/6 "2021-07-09T11:50:54Z")

</div>

Move:  
`TGraphErrors* g = new TGraphErrors;`  
to right before:  
`for(int a=0.0;a<n;a++){`  
and move:  
`g->SetMarkerStyle(20); g->Draw("AP");`  
to right before:  
`return 0;`

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 9, 2021, 11:58am UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/7 "2021-07-09T11:58:51Z")

</div>

Can you post the corrected version of your macro ?

---

<div class="post-metadata">

**Author:** ![mai1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mai1](https://root-forum.cern.ch/u/mai1)\
**Post date:** [July 9, 2021, 1:48pm UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/8 "2021-07-09T13:48:25Z")

</div>

I did it well! thank you very much! !!

---

<div class="post-metadata">

**Author:** ![mai1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mai1](https://root-forum.cern.ch/u/mai1)\
**Post date:** [July 9, 2021, 1:49pm UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/9 "2021-07-09T13:49:43Z")

</div>

solved. I’m sorry for making a noise.  
I’m really thankful to you!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 23, 2021, 1:49pm UTC](https://root-forum.cern.ch/t/linking-cling-interface-function/45765/10 "2021-07-23T13:49:46Z")

</div>

Closed on July 23, 2021, 1:49pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
