Compiling several source (main and headers) files and linking them?

Finally solved it, the last reply to the question: Is there any tutorial on running root entirely with g++? is related to this question and solves the problem. Thanks everyone.