How to pragmatically add canvas and text in unity 5.1

I am trying to add the Canvas an text programatically so that I have references to it and can control it run time. I am following this method discussed here:
http://forum.unity3d.com/threads/creating-a-gui-from-code.263563/

This seems to be out of date in 5.1 because it does not recognise the using statements:

using UnityEngine.EventSystems;
using UnityEngine.UI;

I am very accustom to using code and not using prefabs and monobehaviours.
What should I do?

If you’re just looking to add some text to the screen here are the basics:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TextUI : MonoBehaviour {

    void Start()
    {
        GameObject canvObj = new GameObject("Canvas");
        Canvas canv = canvObj.AddComponent<Canvas>();
        RectTransform canvTransform = canv.GetComponent<RectTransform>();
        canv.renderMode = RenderMode.ScreenSpaceOverlay;

        GameObject txtObj = new GameObject("Text");
        Text txt = txtObj.AddComponent<Text>();
        txtObj.transform.SetParent(canv.transform, false);
        txt.font = Font.CreateDynamicFontFromOSFont("Arial", 16);
        txt.alignment = TextAnchor.UpperCenter;

        txt.text = "Foo";
    }

}

Note that to add buttons you’ll also need to put in an Event System for the events to work.

I needed to include this dll:
Path_To_Unity_Installation/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll