the campatibility among GPU and cuda version

I compiled a program on a computer with cuda2.3 and GTX295.
When I run it on a computer with cuda2.2 and TeslaC1060, it reported cufft_invalid_plan.
How can i compile a cuda program which can run on all kinds of cuda device and doesn’t need to re-compile it ?