ROOT macro does not compile in OSx

I am beginner with ROOT macros.
When I try to compile the following code,

|#include "TCanvas.h"
#include "TROOT.h"
#include "TGraphErrors.h"
#include "TF1.h"
#include "TLegend.h"
#include "TArrow.h"
#include "TLatex.h"
#include "TH1.h"
void macro5(){

  auto cnt_r_h= new TH1F("count_rate","Count Rate;N_{Counts};#occurences",100,-0.5,15.5);

  auto mean_count=3.6f;
  TRandom3 rndgen;

  for(int imeas=0;imeas<400;imeas++){cnt_r_h->Fill(rndgen.Poisson(mean_count));}

  auto c= new TCanvas();

   auto c_norm= new TCanvas();

  cout << "Moments of distribution: \n "
       << "Mean         "<< cnt_r_h->GetMean();


the following error appears

You are probably missing the definition of std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)
Maybe you need to load the corresponding shared library?

But it happens only in the MacOs pc I am using.
Expected output is displayed when I execute the same code in my school’s official server.
Would anyone please help me to find out the exact reason behind the problem?
Thank you.

Hi Ahmed,

I tried to run your macro on linux and osx (10.13), ROOT 6.12/06, with root -b -q and it works for me: if by “compile” you mean use aclic, I am not sure how necessary it is, but if you want to you need to complete the set of headers you include.


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