Animated gif, SaveAs() only runs once

I’m trying to make an animated gif. The animation works when the macro is run but it doesn’t save. I end up with a saved single gif image.

This is my loop

for(int i = 0; i < 100; i++){

    text -> Clear();     //TPaveText


    dummy -> Draw();    //TH1D 
    dummy -> SetTitleSize(0.02,"y");
    dummy -> SetTitleOffset(2,"y");


    //Timer
    to_str << fixed << setprecision(1) << t[i];
    time = "t = " + to_str.str();
    c = time.c_str();
    text -> AddText(c);                                   
    to_str.str(clear);

    //Position display
    to_str << fixed << setprecision(1) << y[i];
    time = "Position  " + to_str.str();
    c = time.c_str();
    text -> AddText(c);
    to_str.str(clear);

    //Velocity display
    to_str << fixed << setprecision(1) << v[i];
    time = "Velocity  " + to_str.str();
    c = time.c_str();
    text -> AddText(c);
    to_str.str(clear);
    ((TText*)text->GetListOfLines()->Last())->SetTextColor(kBlue);

    //Acceleration display
    to_str << fixed << setprecision(1) << a[i];
    time = "Acceleration  " + to_str.str();
    c = time.c_str();
    text -> AddText(c);
    to_str.str(clear);
    ((TText*)text->GetListOfLines()->Last())->SetTextColor(kRed);

    //Draw Text Box
    text -> SetTextSizePixels(20);
    text -> SetTextAlign(16.15);
    text -> Draw();


    //Mark top of jump
    top -> Draw();                    //Tline

    //Draw bungee cord
    cord -> SetY2(y[i]);           //TLine
    cord -> Draw();

    //Draw jumper
    man -> DrawMarker(10,y[i]); //TMarker

    //Draw velocity arrow
    vel_arrow -> SetX1(10.50);        //TArrow
    vel_arrow -> SetY1(y[i]);
    vel_arrow -> SetX2(10.50);
    vel_arrow -> SetY2(y[i] + v[i]);
    vel_arrow -> SetArrowSize(fabs(v[i]/(1000)));
    vel_arrow -> Draw();

    //Draw acceleration arrow
    acc_arrow -> SetX1(9.50);                  //TArrow
    acc_arrow -> SetY1(y[i]);
    acc_arrow -> SetX2(9.50);
    acc_arrow -> SetY2(y[i] + a[i]);
    acc_arrow -> SetArrowSize(fabs(a[i]/(1000)));
    acc_arrow -> Draw();

    myCanvas -> Modified();             // TCanvas
    myCanvas -> Update();
    myCanvas -> SaveAs("myCanvas.gif+1");

    myCanvas -> Clear();


}

All that gets saved is the first frame of the animation. I seems like SaveAs() only executes once even though there are many iterations. I’ve also tried Print(“myCanvas.gif+1”) but got the same result.

I’m running root 5 on ubuntu 16.04. I’m working on updating everything to see if that helps, but until then, any help would be appreciated.

When I run the following macro with root 6 on Mac I get an animated gif which loops.

{
   TCanvas* c = new TCanvas();
   TPaveText* t = new TPaveText(0.55,0.65,0.8,0.85,"brNDC");

   t->AddText("1");
   t->Draw();
   c->Print("animg.gif+100");

   t->AddText("2");
   t->Draw();
   c->Print("animg.gif+100");

   t->AddText("3");
   t->Draw();
   c->Print("animg.gif+100");

   t->AddText("4");
   t->Draw();
   c->Print("animg.gif++");
}