Unresolved symbol while linking error upon second run of macro


I’m trying to run a very simple test script for working with vectors on ROOT6.18/00:

#include "TFile.h"
#include "TTree.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include <iostream>
#include <vector>

using namespace std;

vector<float> compute_a1();

void test(){
    vector<float> coeffs;
    coeffs = compute_a1();

    cout << coeffs.size() + 5 << endl;

vector<float> compute_a1(){
    vector<float> coeffs;

    return coeffs;

When running using ‘.x test.C’ it runs fine the first time but running again using the same command throws the following linking error:

IncrementalExecutor::executeFunction: symbol ‘ZSt15__alloc_on_moveISaIfEEvRT_S2’ unresolved while linking [cling interface function]!
You are probably missing the definition of void std::__alloc_on_move<std::allocator >(std::allocator&, std::allocator&)
Maybe you need to load the corresponding shared library?

I’ve tried searching for this error and the closest topic that I found is this one: Std::vector - unresolved while linking. I’ve tried some of the solutions mentioned in this thread (including compiling using .L test.C and running test(), but this throws the same error as above if I change the file). I could restart root everytime I need to run but I foresee that this will get extremely tedious for future code debugging especially when I need to run the code multiple times so I was just wondering if there was an alternate solution, or if I will have to resort to restarting root.

Thanks for the help,


_ROOT Version: 6.18/00
_Platform: Scientific Linux release 6.10 (Carbon)
_Compiler: GCC 8.3.0

You probably need at least ROOT 6.20/00 (in previous ROOT 6 versions, macro unloading / reloading was not working / not supported).

Note: in any version, if you do not need to modify your macro, you can use:

root [0] .x test.C
root [1] test();

Apologies, I made a mistake in my original post about the version of root, it should instead read 6.18/00, I realize that it is still not 6.18/04, but I just wanted to make you aware that I was not using a 6.14 release.

EDIT: Wile, I tried your suggestion I still get the error after .x test.C but I get the correct output upon running test(). Thanks.