The prototype for the ttyname() function wasn't in /usr/include/unistd.h so you will have to add it to the bottom of the file: char * ttyname(int fildes);