First, how can we get your problems if you don't show us the whole code.
Post it on a pastebin.
And second, try to look at the message errors and google them up.
Undefined reference might be caused by the compiler and the .o file, the compiler can't link it.
Or you haven't defined those variables, you may forgot to use libraries "#include ...".