how (and where/when) does -lpq get manipulated to cause it to add the reference to -llibpq
You compiler (cl) doesn't understand the -l switch, so MakeMaker converts the -lpq to libpq.lib in order that your compiler will be able to make use of it. Changing the -lpq to -lpq64 in the LIBS assignment should fix things for you.