ROOT crashes: Error in <ACLiC>: Compilation failed!

void copytree(){   
	TChain * chains=new TChain("orange");
   	Float_t Z_Eventnr;
	chains->SetBranchAddress("Eventnr", &Z_Eventnr);
	Float_t Z_Runnr;
	chains->SetBranchAddress("Runnr", &Z_Runnr);
	Float_t Z_Sincand;
	chains->SetBranchAddress("Sincand", &Z_Sincand);
	Float_t Z_Siprob;
	chains->SetBranchAddress("Siprob", &Z_Siprob);
	Float_t Z_Siyel;
	chains->SetBranchAddress("Siyel", &Z_Siyel);
	Float_t Z_Tltw;
	chains->SetBranchAddress("Tltw", &Z_Tltw);
	Float_t Z_Zvtx;
	chains->SetBranchAddress("Zvtx", &Z_Zvtx);
	Float_t Z_Cal_tb ;
	chains->SetBranchAddress("Cal_tb", &Z_Cal_tb);
	Float_t Z_Cal_pt;
	chains->SetBranchAddress("Cal_pt", &Z_Cal_pt);
	Float_t Z_Cc_yjb;
	chains->SetBranchAddress("Cc_yjb", &Z_Cc_yjb);
	Float_t Z_Etamax_zu4;
	chains->SetBranchAddress("Etamax_zu4", &Z_Etamax_zu4);
	Float_t Z_Trk_px;
	chains->SetBranchAddress("Trk_px", &Z_Trk_px);
	Float_t Z_Trk_py;
	chains->SetBranchAddress("Trk_py", &Z_Trk_py);
	Float_t Z_Trk_pz;
	chains->SetBranchAddress("Trk_pz", &Z_Trk_pz);
	Float_t Z_Nzufos;
	chains->SetBranchAddress("Nzufos", &Z_Nzufos);
	Float_t Z_Tufo;
	chains->SetBranchAddress("Tufo", &Z_Tufo);
	Float_t Z_Zufo;
	chains->SetBranchAddress("Zufo", &Z_Zufo);
	Float_t Z_Zufo_deltaz;
	chains->SetBranchAddress("Zufo_deltaz", &Z_Zufo_deltaz);
	Float_t Z_Zufoeemc;
	chains->SetBranchAddress("Zufoeemc", &Z_Zufoeemc);
	Float_t Z_Zufoecal;
	chains->SetBranchAddress("Zufoecal", &Z_Zufoecal);
	Float_t Z_Zufo_fmax_bemc;
	chains->SetBranchAddress("Zufo_fmax_bemc", &Z_Zufo_fmax_bemc);
	Float_t Z_Trk_ntracks;
	chains->SetBranchAddress("Trk_ntracks", &Z_Trk_ntracks);

	TFile *newfile = new TFile("tree.root","recreate");
	TTree *newtree = chains->CloneTree();


   	delete oldfile;
   	delete newfile;
	delete chains;
	//return 0;

After compiling i have this errors:

When i build it:

Interesting that first time it has copied branches correctly, but only one time. After it i build it and new tree creates unclosed (how i’ve understood) - in TBrowser i can’t open it. What i’m doing wrong?
P.S. Sry for my bad english.
P.P.S. OS: Ubuntu 14.04, ROOT: 5.34/14


Sorry for the late reply.
Not sure this post has anything to do with PROOF.

Not sure to understand your problem.
First, your script misses several includes (at least TROOT.h, TChain.h, TFile.h) and has some undefined variable (oldfile). Once you fix these you should be able to compile it.

It is not clear, then, what you would like to do in your script.
Is this to extract a Tree from a file and save it into another? Why do you think you need a TChain ?

G. Ganis