>What is makefile?
Basically a list of instructions sent to the compiler/linker, including things such as the files to compile, paths, libraries, etc. You don't need one, but it sure beats typing out a long command everytime you want to compile your project.
>How does it work?
On *nix systems, you invoke the makefile with the [search]make[/search] command.
>Is it done in the terminal?
The file can be written in any text editor, but yes, you'll need a terminal to run make .
>I am having trouble in compiling my c++ source codes
What are you trying to compile? Source code that you wrote? What errors came up?
>Do you have any suggestions where I could find complete manuals in compiling c++ codes?
You can always check out the Unix man pages of the varioius tools, such as gcc/g++, make, etc. Furthermore, if you can use an IDE, do it, because it saves you the trouble of dealing with makefiles (although it's still a good idea to learn both).