Well, it turns out it has nothing to do with code::blocks but with the fact that I have cygwin in my path. Is there a reason why Code::Blocks is launching link.exe from the path instead of directly from the specified location?
I fixed this by specifying the full path to link.exe(C:\Program Files\Microsoft Visual Studio 8\VC\bin\link.exe) in Code::Block's compiler settings.