Hi everibody
I’m trying to compile a new program with one class that it creates some vector with data. I want to use this vector in my program to fill some histograms.
When I try to run the program, root takes me out this error:
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster11GetCentroidEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetCentroid()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster13isGoodClusterEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::isGoodCluster(int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster8GetSum_qEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetSum_q()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster12GetN_ClusterEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetN_Cluster()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::Cluster(std::map<int, int, std::less, std::allocator<std::pair<int const, int> > >&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster8GetChambB5cxx11Ev’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetChambabi:cxx11
Maybe you need to load the corresponding shared library?
where the various Cluster::GetChamb() etc are the function that I have declared in my Class Cluster.
#ifndef _CLUSTER_CXX_
#define _CLUSTER_CXX_
#include "header_files/cluster.h"
#include "../prova.h"
#include <iostream>
#include <vector>
#include <string.h>
#include <map>
#include "TROOT.h"
using namespace std;
Cluster::Cluster(map<int, int> &map, string &name)
{
this->reset();
if(map.size()>1){
_n_clu = 0;
vector<int> temp_cluster, temp_max_q, vec_strip, vec_max_q;
for (std::map<int,int>::iterator it=map.begin(); it!=map.end(); it++){
vec_strip.push_back(it->first);//copio gli elementi della mappa su due vettori d'appoggio
vec_max_q.push_back(it->second);
}
unsigned int k = 0;//variabile che mi tiene conto dello scorrere degli elementi dei vettori
while(k<(vec_strip.size()-1)){//giro su tutto il vettore delle strip
int j = 0; //variabile che mi tiene conto del numero di volte che sono entrato nel ciclo
double centroid_coord = 0;
int temp_q_sum = 0;//variabili per il calcolo del centroide
while((k<(vec_strip.size()-1)) && ((vec_strip.at(k+1) - vec_strip.at(k)) <= 3)){//controllo cluster
if((vec_strip.at(k+1) - vec_strip.at(k)) == 2)
_n_holes++;
if(j<1){//ci entro solo all'inizio del cluster
temp_cluster.push_back(vec_strip.at(k));//riempio i vettori con gli elementi dell'inizio del cluster
temp_max_q.push_back(vec_max_q.at(k));
centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
temp_q_sum += vec_max_q.at(k);
}
temp_cluster.push_back(vec_strip.at(k+1));//riempio i vettori con gli elementi successivi del cluster
temp_max_q.push_back(vec_max_q.at(k+1));
centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
temp_q_sum += vec_max_q.at(k+1);
j++;//tiene conto della grandezza del cluster
k++;
}
if(j > 10 || _n_holes > n_holes_max){//controllo che il cluster non sia troppo grande
temp_cluster.clear();
temp_max_q.clear();
centroid_coord = 0;
temp_q_sum = 0;
}else if(j!= 0 && j<= 10){//controllo che il cluster ci sia e che sia minore di 10 strips. Inoltre calcolo il centroide
_n_clu++;
for(UInt_t i = 0; i<temp_cluster.size(); i++){
_strip.push_back(temp_cluster.at(i));//riempio il vettore con le strip del cluster
_max_q.push_back(temp_max_q.at(i));//riempio il vettore con la carica delle strip
_chamb.push_back(name); //riempio il vettore con il nome della camera a cui appartiene il cluster
if(i == 0){
_sum_q.push_back(temp_q_sum);
_n_cluster.push_back(_n_clu);//do un numero al cluster
_centroid.push_back(centroid_coord/temp_q_sum);//mi segno il valore del centroide del cluster
_pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1);
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
}else{
_sum_q.push_back(0);
_n_cluster.push_back(0);//do un numero al cluster
_centroid.push_back(0);//mi segno il valore del centroide del cluster
_pcb.push_back(0);
}
}
temp_cluster.clear();//svuoto entrambi i vettori dei cluster
temp_max_q.clear();
}
while((k<(vec_strip.size()-1)) && ((vec_strip.at(k+1) - vec_strip.at(k))>3)){//se non c'è un cluster, comunque scorro sul vettore con il k
k++;
}
}
}
}
void Cluster::reset(){
_strip.clear();
_chamb.clear();
_max_q.clear();
_centroid.clear();
_sum_q.clear();
_n_cluster.clear();
_pcb.clear();
_pcb_n_cluster.clear();
_n_holes = 0;
}
vector<string> Cluster::GetChamb()
{
return _chamb;
}
vector<double> Cluster::GetCentroid()
{
return _centroid;
}
vector<int> Cluster::GetClusterStrip()
{
return _strip;
}
vector<int> Cluster::GetClusterMax_q()
{
return _max_q;
}
vector<int> Cluster::GetSum_q()
{
return _sum_q;
}
int Cluster::GetN_Cluster()
{
return _n_clu;
}
vector<int> Cluster::GetPCB()
{
return _pcb;
}
Cluster::isGoodCluster(int charge_min, string &name) const
{
for(UInt_t i = 0; i<chamb.size(); i++){
if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
return false;
}
return true;
}
What could be the probelm?
In your “prova.cxx”, try to replace #include "header_files/cluster.h" with #include "header_files/cluster.cxx" (assuming that this “.cxx” file is also in “header_files”).
The first substitution doesn’t work. In fact root doesn’t find the declaration of the function that I declared in cluster.h.
The compilation of cluster.cxx before prova.cxx give me some error because i use some variable defined in prova.h that he doesn’t find.
But if i try with:
root[0] .L prova.cxx++
root[1] prova t
root[2] t.Loop()
it returns:
Error in <TString::Replace>: first argument out of bounds: pos = -1, Length = 6
[0%]
/home/leonardo/Programs/rootbuild/bin/root.exe: symbol lookup error: /home/leonardo/Scrivania/Roba/TBReco/vediamosefunziona_cxx.so: undefined symbol: _ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
the [0%] is a part of my program that says me the percentage of data analized
If I simply copy-paste the code snippets as cluster.h and cluster.cxx and then try to compile the cluster.cxx in root I get
root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:4:10: fatal error: 'header_files/cluster.h' file not found
#include "header_files/cluster.h"
^~~~~~~~~~~~~~~~~~~~~~~~
Error in <ACLiC>: Dictionary generation failed!
This means that I cannot test that files and reproduce your problem. If you want to get help you should prepare MWE, i.e. minimal working example. As I shown your example is not MWE.
OK, I removed header_files and tried again:
root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:5:10: fatal error: '../prova.h' file not found
#include "../prova.h"
^~~~~~~~~~~~
Error in <ACLiC>: Dictionary generation failed!
Again, I cannot reproduce your problem because you didn’t provide MWE.
Now let’s go on third round where I commented that header file:
root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:35:41: error: use of undeclared identifier 'pitch'
centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
^
././cluster.cxx:40:42: error: use of undeclared identifier 'pitch'
centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
^
././cluster.cxx:45:28: error: use of undeclared identifier 'n_holes_max'
if(j > 10 || _n_holes > n_holes_max){//controllo che il cluster non sia troppo grande
^
././cluster.cxx:60:58: error: use of undeclared identifier 'pitch'
_pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1);
^
././cluster.cxx:61:7: error: use of undeclared identifier 'pcb_n_cluster'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^
././cluster.cxx:61:57: error: use of undeclared identifier 'pitch'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^
././cluster.cxx:61:79: error: no matching function for call to 'atoi'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^~~~
/usr/include/stdlib.h:104:12: note: candidate function not viable: no known conversion from 'std::__cxx11::string' (aka 'basic_string<char>') to 'const char *' for 1st argument
extern int atoi (const char *__nptr)
^
In file included from input_line_12:9:
././cluster.cxx:86:2: error: use of undeclared identifier '_pcb_n_cluster'
_pcb_n_cluster.clear();
^
././cluster.cxx:117:10: error: C++ requires a type specifier for all declarations
Cluster::isGoodCluster(int charge_min, string &name) const
^
././cluster.cxx:119:22: error: use of undeclared identifier 'chamb'
for(UInt_t i = 0; i<chamb.size(); i++){
^
././cluster.cxx:120:6: error: use of undeclared identifier 'chamb'
if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
^
././cluster.cxx:120:29: error: use of undeclared identifier 'cluster_max_q'
if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
^
././cluster.cxx:1:2: error: unterminated conditional directive
#ifndef _CLUSTER_CXX_
^
Error in <ACLiC>: Dictionary generation failed!
Conclusion: the data that you provide to us not enough to reproduce your issue and to help you in any manner.
Before continue try the following: make a temporary directory, copy to there only necessary files (for example, copy just two, compile them, if there are errors about missing files just add that files, repeat). And after that if you see the same problem with compilation (I don’t understand do you mean compilation by a compiler like GCC or CLANG or ROOT/CLING compilation, please be more concrete) provides the MWE (files in the temporary directory) here so we could try on our side. Also give details how do you compile the file, what file and ROOT version, OS and compilers on your system.
Sorry man, this is the prova.h that i didn’t post before:
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Fri Mar 30 12:27:06 2018 by ROOT version 6.12/06
// from TTree apv_raw/APVRawData
// found on file: ../TBReco/data/run177.root
//////////////////////////////////////////////////////////
#ifndef prova_h
#define prova_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH1F.h>
#include <TH2F.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <TCanvas.h>
// Header file for the classes stored in the TTree if any.
#include "vector"
#include "vector"
#include "vector"
#include "vector"
#include "vector"
using namespace std;
class prova {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Fixed size dimensions of array or collections stored in the TTree if any.
// Declaration of leaf types
//IMPOSTO ANGOLO E LARGHEZZA IN STRIP DELLA ROAD
//Double_t cos(angle_2) = 0.982416299;
map<int,int> infncard;
string _ch_p1 = "P1_M01", _ch_p2 = "P2_M01", _ch_p3 = "P3_M01", _ch_p4 = "P4_M01";
Double_t _super_eta;
Int_t _N_lay = 4;
Int_t _N_pcb = 5;
Int_t eff_num = 0;
Int_t make_fit = 0;
Double_t pitch = 0.425; //mm
//double temp_centroid[4];
int n_volte = 0;
int eff_evt = 0;
int n_event = 0;
double temp_centroid_pcb[20];
int n_clu_1, n_clu_2, n_clu_3, n_clu_4;
int pcb_n_cluster[20];
double num_eff[4];
double den_eff[4];
double num_fit_eff[4];
double den_fit_eff[4];
double num_hist_eff[4];
double den_hist_eff[4];
int n_holes_max = 2;
Double_t n_sigma = 4;
Double_t angle = 0.0261799, phi = 0.183;
Double_t major_base = 1319.2;
Double_t road_eta = 2;
double sigma_road = 1.;
//Double_t road_stereo = 2*(()*tan(angle) + sigma_road);
map<int,int> ch1, ch2, ch3, ch4;
vector<double> res_1, res_2, res_3, res_4;
vector<TH1F*> h_residues_pos;
vector<TH1F*> h_residues_pos_fit;
vector<TH2F*> h2_extrapolate_pos;
vector<TH2F*> h2_extrapolate_pos_fit;
vector<TH1F*> num_eff_pos;
vector<TH1F*> den_eff_pos;
vector<TH1F*> eff_pos;
ULong64_t evt;
UInt_t error;
Int_t daqTimeSec;
Int_t daqTimeMicroSec;
Int_t srsTimeStamp;
UInt_t srsTrigger;
vector<double> *ped_stdev;
vector<double> *ped_mean;
vector<char> *ped_readout;
vector<string> *ped_chamb;
vector<int> *ped_Strip;
vector<int> *ped_layer;
vector<unsigned int> *srsFec;
vector<unsigned int> *srsChip;
vector<unsigned int> *srsChan;
vector<string> *mmChamber;
vector<int> *mmLayer;
vector<char> *mmReadout;
vector<int> *mmStrip;
vector<vector<short> > *raw_q;
vector<short> *max_q;
vector<int> *t_max_q;
vector<int> ped_strip_tmm;
vector<string> ped_chamb_tmm;
vector<int> strip;
vector<int> cluster_max_q;
vector<string> chamb;
vector<int> pcb;
vector<double> centroid;
vector<int> q_sum;
vector<int> n_cluster;
// List of branches
TBranch *b_evt; //!
TBranch *b_error; //!
TBranch *b_daqTimeSec; //!
TBranch *b_daqTimeMicroSec; //!
TBranch *b_srsTimeStamp; //!
TBranch *b_srsTrigger; //!
TBranch *b_srsFec; //!
TBranch *b_srsChip; //!
TBranch *b_srsChan; //!
TBranch *b_mmChamber; //!
TBranch *b_mmLayer; //!
TBranch *b_mmReadout; //!
TBranch *b_mmStrip; //!
TBranch *b_raw_q; //!
TBranch *b_max_q; //!
TBranch *b_t_max_q; //!
prova(TTree *tree=0);
virtual ~prova();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
//virtual void Cluster(map<int,int>&, string&, int&);
virtual void Mapping(map<int,int>&,string&);
virtual void Output_ped(ofstream&);
virtual void Output_strip(ofstream&);
//virtual void Histo_PCB(vector<TH1F*>&, vector<TH1F*>&, vector<TH1F*>&, map<int,int>&, int strip_pcb[], int );
virtual void Inizializ();
virtual bool DAQCount(string&);
virtual void Efficiency_Fit_1();
virtual void Efficiency_Fit_2();
virtual void Efficiency_Fit_3();
virtual void Efficiency_Fit_4();
virtual void FitParameters(double&, double&, double&, double&, double&, double&, double par[]);
virtual void Efficiency_1();
virtual void Efficiency_2();
virtual void Efficiency_stereo();
virtual void parameters(double&, double&, double&, double&, double par[]);
virtual void Efficiency_Position_1();
virtual void Efficiency_Position_2();
virtual void Efficiency_Position_Stereo();
virtual int Stereo_Road(double&);
virtual void Histo_Layer(vector<TH1F*>&, vector<TH1F*>&, vector<TProfile*>&, vector<TH2F*>&, vector<TH1F*>&, map<int,int>&, int );
virtual void mapINFNcards();
//virtual void Histo_ped(map<int,int>&,vector<TH1F*>&, string&);
private:
TString _outdirname;
TString _outdirname_pcb;
TString _outdirname_ped, _outdirname_lay;
};
#endif
#ifdef prova_cxx
prova::prova(TTree *tree) : fChain(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("data/run177.root");
if (!f || !f->IsOpen()) {
f = new TFile("data/run177.root");
}
f->GetObject("apv_raw",tree);
}
Init(tree);
}
prova::~prova()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t prova::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t prova::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void prova::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set object pointer
srsFec = 0;
srsChip = 0;
srsChan = 0;
mmChamber = 0;
mmLayer = 0;
mmReadout = 0;
mmStrip = 0;
raw_q = 0;
max_q = 0;
t_max_q = 0;
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("evt", &evt, &b_evt);
fChain->SetBranchAddress("error", &error, &b_error);
fChain->SetBranchAddress("daqTimeSec", &daqTimeSec, &b_daqTimeSec);
fChain->SetBranchAddress("daqTimeMicroSec", &daqTimeMicroSec, &b_daqTimeMicroSec);
fChain->SetBranchAddress("srsTimeStamp", &srsTimeStamp, &b_srsTimeStamp);
fChain->SetBranchAddress("srsTrigger", &srsTrigger, &b_srsTrigger);
fChain->SetBranchAddress("srsFec", &srsFec, &b_srsFec);
fChain->SetBranchAddress("srsChip", &srsChip, &b_srsChip);
fChain->SetBranchAddress("srsChan", &srsChan, &b_srsChan);
fChain->SetBranchAddress("mmChamber", &mmChamber, &b_mmChamber);
fChain->SetBranchAddress("mmLayer", &mmLayer, &b_mmLayer);
fChain->SetBranchAddress("mmReadout", &mmReadout, &b_mmReadout);
fChain->SetBranchAddress("mmStrip", &mmStrip, &b_mmStrip);
fChain->SetBranchAddress("raw_q", &raw_q, &b_raw_q);
fChain->SetBranchAddress("max_q", &max_q, &b_max_q);
fChain->SetBranchAddress("t_max_q", &t_max_q, &b_t_max_q);
/*
h_sum_q_cluster_ch1 = new TH1F("h_sum_q_cluster_ch1","Distribution sum of charge in cluster P1_M01;sum_q_P1_M01;Entry",150,0.0,5000.);
h_sum_q_cluster_ch2 = new TH1F("h_sum_q_cluster_ch2","Distribution sum of charge in cluster P2_M01;sum_q_P2_M01;Entry",150,0.0,5000.);
h_sum_q_cluster_ch3 = new TH1F("h_sum_q_cluster_ch3","Distribution sum of charge in cluster P3_M01;sum_q_P3_M01;Entry",150,0.0,5000.);
h_sum_q_cluster_ch4 = new TH1F("h_sum_q_cluster_ch4","Distribution sum of charge in cluster P4_M01;sum_q_P4_M01;Entry",150,0.0,5000.);
h_sum_q_centroid_ch1 = new TH2F("h_sum_q_centroid_ch1","Histo sum of charge vs centroid P1_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);
h_sum_q_centroid_ch2 = new TH2F("h_sum_q_centroid_ch2","Histo sum of charge vs centroid P2_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);
h_sum_q_centroid_ch3 = new TH2F("h_sum_q_centroid_ch3","Histo sum of charge vs centroid P3_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);
h_sum_q_centroid_ch4 = new TH2F("h_sum_q_centroid_ch4","Histo sum of charge vs centroid P4_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);
*/
Notify();
}
Bool_t prova::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void prova::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t prova::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
#endif // #ifdef prova_cxx
so now you have:
prova.h
prova.cxx
cluster.h
cluster.cxx
I did as you said, I put all the files in one directory and i run prova.cxx in this way:
root[0] .L prova.cxx
root[1] prova t
root[2] t.Loop()
now the problem is
*** Break *** segmentation violation
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x00007f1c1ea52e17 in prova::Loop() () from /home/leonardo/Scrivania/Roba/TBReco/vediamosefunziona_cxx.so
#7 0x00007f1c1bf3a070 in ?? ()
#8 0x0000000101a14c08 in ?? ()
#9 0x000000000196b5d0 in ?? ()
#10 0x00007f1c272f3870 in ?? () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#11 0x00007fffbd2c3740 in ?? ()
#12 0x00007fffbd2c3380 in ?? ()
#13 0x00007f1c27284386 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.290] [clone .constprop.443] () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#14 0x00007f1c27288b1d in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#15 0x00007f1c27288d25 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#16 0x00007f1c27317ed7 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#17 0x00007f1c2721052a in HandleInterpreterException (metaProcessor=0x1b02e70, input_line=0x61809c0 "#line 1 "ROOT_prompt_2"nt.Loop()", compRes=
0x7fffbd2c372c: cling::Interpreter::kSuccess, result=result
entry=0x7fffbd2c3740) at /home/leonardo/Programs/root-6.12.06/core/metacling/src/TCling.cxx:2071
===========================================================
I saved code snippets from your first message as cluster.h and cluster.cxx (that file missed #endif). The code that you post for prova.h and prova.cxx is a bit contradicted. I saved them as prova.h and prova.cxx (please check if these are OK, because I had to merge two snippets and reformat all files to one style).
Now I get
root[0] .L prova.cxx
root[1] prova t;
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster13isGoodClusterEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::isGoodCluster(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster8GetChambB5cxx11Ev' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetChamb[abi:cxx11]()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::Cluster(std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster11GetCentroidEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetCentroid()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster8GetSum_qEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetSum_q()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster12GetN_ClusterEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetN_Cluster()
Maybe you need to load the corresponding shared library?
AFAIU, this means that cluster.cxx file is not processed. AFAIU, I have to load cluster class first but this raises another issue:
root[0] .L cluster.cxx
In file included from input_line_10:1:
/home/vladimir/tmp/root/cluster.cxx:40:46: error: use of undeclared identifier 'pitch'
centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
^
/home/vladimir/tmp/root/cluster.cxx:45:46: error: use of undeclared identifier 'pitch'
centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
^
/home/vladimir/tmp/root/cluster.cxx:50:31: error: use of undeclared identifier 'n_holes_max'
if(j > 10 || _n_holes > n_holes_max)
^
/home/vladimir/tmp/root/cluster.cxx:71:59: error: use of undeclared identifier 'pitch'
_pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1);
^
/home/vladimir/tmp/root/cluster.cxx:72:8: error: use of undeclared identifier 'pcb_n_cluster'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^
/home/vladimir/tmp/root/cluster.cxx:72:58: error: use of undeclared identifier 'pitch'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^
/home/vladimir/tmp/root/cluster.cxx:72:80: error: no matching function for call to 'atoi'
pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
^~~~
/usr/include/stdlib.h:104:12: note: candidate function not viable: no known conversion from 'std::__cxx11::string' (aka 'basic_string<char>') to 'const char *' for 1st argument
extern int atoi (const char *__nptr)
^
In file included from input_line_10:1:
/home/vladimir/tmp/root/cluster.cxx:102:3: error: use of undeclared identifier '_pcb_n_cluster'
_pcb_n_cluster.clear();
^
/home/vladimir/tmp/root/cluster.cxx:141:10: error: C++ requires a type specifier for all declarations
Cluster::isGoodCluster(int charge_min, string &name) const
^
/home/vladimir/tmp/root/cluster.cxx:143:23: error: use of undeclared identifier 'chamb'
for(UInt_t i = 0; i<chamb.size(); i++)
^
/home/vladimir/tmp/root/cluster.cxx:145:8: error: use of undeclared identifier 'chamb'
if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
^
/home/vladimir/tmp/root/cluster.cxx:145:31: error: use of undeclared identifier 'cluster_max_q'
if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
^
At this point I think that your example has issues with the program itself not the ROOT. I don’t understand why you get SEGFAULT on this example, may be there is a problem with your ROOT installation. Are you sure that you were able to compile this code before?
P.S. I’m not sure about your code, I could modify it so that it could be compiled and be run but I don’t know what you do and what you want to achieve with it.
In fact, I wasn’t able to change these files in such a way as to make them compilable. I had to change too many parts of codes but stuck on code that I don’t understand completely (too many variables, some of them are used in different classes and etc).