We present GM2Calc, a public C++ program for the calculation of MSSM contributions to the anomalous magnetic moment of the muon, (g −2)μ. The code computes (g −2)μ precisely, by taking into account the latest two-loop corrections and by performing the calculation in a physical on-shell renormalization scheme. In particular the program includes a tan β resummation so that it is valid for arbitrarily high values of tan β, as well as fermion/sfermion-loop corrections which lead to non-decoupling effects from heavy squarks. GM2Calc can be run with a standard SLHA input file, internally converting the input into on-shell parameters. Alternatively, input parameters may be specified directly in this on-shell scheme. In both cases the input file allows one to switch on/off individual contributions to study their relative impact. This paper also provides typical usage examples not only in conjunction with spectrum generators and plotting programs but also as C++ subroutines linked to other programs.