When was Stirling Castle built?

No one can confirm when Stirling castle was first built, but references to it begin to appear in historical records of the early 12th Century