Missing dictionaries in Xcode

I run the attached code in my Xcode project and I get the following error message at runtime:
[ul]Error in TTree::Branch: The pointer specified for mystring is not of a class or type known to ROOT[/ul]
The output file is written and contains myfloat but not mystring.
It is obviously a problem with dictionaries. I tried various incantations suggested in other posts about generating my own dictionary without success. I guess Root must have already dictionaries for such common types as , so the problem must be where those dictionaries are and how do I tell Xcode to get at them.
I’d be grateful for any help you could offer.



I am running Xcode Version 4.6.2 (4H1003)
Mac OS X 10.8.5

Here is my code:

// Adapted from https://root-forum.cern.ch/t/problem-in-getting-the-vector-vector-string-branch/14608/1

#include <string>
#include <vector>

#include "TFile.h"
#include "TTree.h"

void write_tree(const char *file_name = "trial.root")
    if (!file_name || !(*file_name)) return; // just a precaution
    TFile *f = new TFile(file_name, "RECREATE");
    TTree *tree = new TTree("tree", "tree");
    float myfloat;
    tree->Branch("myfloat", &myfloat);
    std::string mystring;
    tree->Branch("mystring", &mystring);
    delete f;

void trial(const char *file_name = "trial.root")
    if (!file_name || !(*file_name)) return; // just a precaution

 int main(int argc, char **)
     trial("trial.root"); // just call the "ROOT Script"
     return 0;

Hi Luciano,

the dictionary for string is included in libCore: it should be there.
Is your root installation ok? Can you run root?
Which version are you using? For example with ROOT6 I cannot reproduce the issue.


I discovered that Xcode, by default, was using “Apple LLVM compiler 4.2” to compile. I switched to “LLVM GCC 4.2” (the option is in the project settings) and my code just worked.


Hi Luciano,

I mark the item as solved.
Just post again if a real problem with dictionaries is identified.