You have to load the url helper to access that function. Either you add
$this->load->helper('url');
somewhere in your controller.
Alternately, to have it be loaded automatically everywhere, make sure the line in application/config/autoload.php that looks like
$autoload['helper'] = array('url');
has 'url'
in that array (as shown above).