Today's first-principles theory of defects in semiconductors focuses on the calculation of the electronic contribution to the energy, for example using density-functional theory in periodic supercells. Although the total zero-point energy is ignored, these calculations lead to reliable total energy differences at T=0K. However, the contributions of the vibrational energy become increasingly large as T increases. In this paper, we discuss the calculations from first-principles of the vibrational (Helmholtz) free energy. The calculations are done in supercells (with k=0) and are based on the normal-mode frequencies obtained from linear response theory. We first show that accurate specific heats and other thermodynamic quantities can be obtained in defect-free Si and GaN supercells. Then, light (H 2 and H 2 * ) and heavy (Cu pairs) impurities are considered, and their total energies computed as function of temperature. In these two cases, the vibrational entropy contributions dominate the changes in total energy differences.