The Moore-Penrose pseudoinverse is probably what you're looking for. The pseudoinverse solution $A^+b$ is the smallest norm $x$ such that $\|Ax-b\|_2$ is minimized. It can be computed using QR decomposition (see here), although you have to use reducedrank-revealing QR when $A$ does not have full column rank. A more complete explanation is given here.