Missing definition on second load of macro

I am extremely new to Root, and even newer to Root 6, but have somehow managed to get an error almost instantaneously; the following code produces an error, but only on the second time I load the macro?

Code:

#include "TROOT.h"
#include <fstream>
#include <string>
#include <numeric>
#include <iterator>
#include <vector>
#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#include "TSystem.h"
#include "TGraph.h"

using namespace std;
using namespace ROOT::Experimental;

//define global variables
int SCOUNT = 1;
vector<double> t1,v1,t2,v2;
vector<double> *vTime = new vector <double>();
vector<double> *vRes = new vector <double>();

void start(){
//create trees
TFile *output = new TFile("process.root","RECREATE");
TTree *f1 = new TTree("f1","Contents of first file");
f1->Branch("vTime1",&t1);
f1->Branch("vRes1",&v1);
TTree *f2 = new TTree("f2","Contents of second file");
f2->Branch("vTime2",&t2);
f2->Branch("vRes2",&v2);
output->GetObject("f1",f1);
output->GetObject("f2",f2);

//create data frame
ROOT::EnableImplicitMT();
TDataFrame d1("file1","process.root");
TFile::Open("process.root");
TDataFrame d2("file2",output);
}//(start)

Error:

IncrementalExecutor::executeFunction: symbol '_ZN9__gnu_cxxL27__exchange_and_add_dispatchEPii' unresolved while linking function '_GLOBAL__sub_I_cling_module_51'!
You are probably missing the definition of __gnu_cxx::__exchange_and_add_dispatch(int*, int)
Maybe you need to load the corresponding shared library?

Thanks in advance for your help,
Alistair


_ROOT Version: 6.12/06
_Platform: Scientific Linux 7.4
_Compiler: GCC 4.8.5


Hi,
it’s only a guess but maybe is due to the fact that you don’t close the TFile.
This can create memory conflict.

Cheers,
Stefano

1 Like

Hi Stefano,

That may be it; I’m moving a macro over from Root5 and when I added more lines in, that hasn’t been among the error list just yet!

Thanks,
Alistair

Hi,
I think this is another incarnation of a known issue with re-running a macro multiple times: https://sft.its.cern.ch/jira/browse/ROOT-9014

In your case I suggest you load the macro once with .L start.C and then execute the function as many times as you want by calling start() explicitly at the prompt.

For better performance you might also want to compile the macro once before executing it many times with .L start.C++ (the ++ specifies you want to compile it) – then you can always execute the function at the prompt with start(), but it will have compiled-C++ speed instead of interpreted-C++ speed.

Cheers,
Enrico

1 Like

Hi Enrico,

Thanks for the details, it’s working okay at the moment, so I’m not going to mess with it!

Thanks again,
Alistair

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