In this Letter we develop theoretical and numerical methods to calculate the dynamic friction coefficient. The theoretical method is based on an adiabatic approximation which allows us to express the dynamic friction coefficient in terms of the time integral of the autocorrelation function of the force between both sliding objects. The motion of the objects and the autocorrelation function can be numerically calculated by molecular-dynamics simulations. We have successfully applied these methods to the evaluation of the dynamic friction coefficient of the relative motion of two concentric carbon nanotubes. The dynamic friction coefficient is shown to increase with the temperature.