Std::vector - unresolved while linking

Hello,
I am trying to work with std::vector in a ROOT macro.
The first time, I run the code, it runs without problem. The second time, it gives me the following error and does not run. I have to restart root and then it works well again.

IncrementalExecutor::executeFunction: symbol ‘ZSt4moveIN9__gnu_cxx17__normal_iteratorIPdSt6vectorIdSaIdEEEES6_ET0_T_S8_S7’ unresolved while linking [cling interface function]!
You are probably missing the definition of __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > > std::move<__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > > >(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator > >)
Maybe you need to load the corresponding shared library?

Am I doing something wrong or is there a problem with my compilation or version of ROOT? Is there a solution to this problem?

I did try the solution given in this thread: Symbol ... unresolved while linking , but the problem remained as it is.

I am also copying a simple code which reproduces the problem.

//R__LOAD_LIBRARY(libTreePlayer)
#include
void sub_vector_simple() {
//create vector
std::vector <Double_t> myVec;
//Add components
for (Int_t i=0;i<10;i++) {
myVec.push_back(i+1000);
}
//erase 4-7
myVec.erase(myVec.begin()+4,myVec.begin()+7);
//print
for(Double_t dd : myVec)
{
cout<<dd<<" "<<endl;;
}
}


ROOT Version: 6.15/01
Platform: Kubuntu 16.04
Compiler: Not Provided


Hi @saesaj

Apologies for the delay, I just tried and I cannot reproduce:

root [0] .L sub_vector_simple.C
root [1] sub_vector_simple()
1000 
1001 
1002 
1003 
1007 
1008 
1009 
root [2] sub_vector_simple()
1000 
1001 
1002 
1003 
1007 
1008 
1009 

It might be a problem with your installation of ROOT. When you say it fails in the second run, you ran the macro twice in the same way I did?

Enric

We have known issues with reloading of code; this is certainly one of them. Your most stable option is to quit ROOT and restart - and believe me, I know just how terrible this is :frowning: I really hope we will be able to tackle this in 2019…

Hi Enric and Axel,
Thank you very much for your replies.

Axel, thank you for letting me know. Right now, I am doing what you said, quitting and restarting. It is a bit annoying, but certainly manageable. I wanted to be certain it wasn’t something I was doing wrong.

Enric, if I run it the way you do, it does not pose problem. It fails when I run .x sub_vector_simple.C twice in a row. Or else it fails if I make a change to the macro, load it again and then try to run it.

root [0] .L sub_vector_simple.C
root [1] sub_vector_simple()
1000 
1001 
1002 
1003 
1007 
1008 
1009 
root [2] .L sub_vector_simple.C
root [3] sub_vector_simple()
IncrementalExecutor::executeFunction: symbol '_ZSt4moveIN9__gnu_cxx17__normal_iteratorIPdSt6vectorIdSaIdEEEES6_ET0_T_S8_S7_' unresolved while linking [cling interface function]!
You are probably missing the definition of __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > > std::move<__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > > >(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >)
Maybe you need to load the corresponding shared library?
root [4] 

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