ROOT on Ubuntu: "no dictionary for class..."

I found this thread: [url]Strange behavior reading TFile in Windows that mentioned a similar problem. It turns out that if I load a “dummy” histogram before opening the file, everything works fine:

#include "TROOT.h"
#include "TSystem.h"
#include "TFile.h"
#include "TH1.h"
#include "TH1F.h"
#include "TAxis.h"

int main(int argc, char *argv[])
{                                                               
  TH1F* dummy = new TH1F("dummy", "dummy", 10, 0, 1);
  TFile *f = new TFile("test.root", "read");
  return 0;
}

However, manually loading libHist and/or a TApplication does not work as far as I can see.

Edit:
It looks like I need I need to load a dummy TH1F regardless of the contents of the file. For example, a TH1F is required even if the file just contains a TTree. If I don’t do that, but instead create a dummy TTree, I get the following error on compilation:

/usr/local/src/root-5.30.03/lib/libNet.so: undefined reference to `gRandom'
A bit odd…