Reordered the arguments to g++ so that -lncurses is last.