I have follow up questions: Why does it have to be compiled in two steps? Why are you using g++ for the second part?
That is the way the Code::Blocks IDE does it.
The two part is common for many IDEs.
Tim S.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson