Core-electron x-ray photoelectron spectroscopy is a powerful technique for studying the electronic structure and chemical composition of molecules, solids and surfaces. However, the interpretation of measured spectra and the assignment of peaks to atoms in specific chemical environments is often challenging. Here, we address this problem and introduce a parameter-free computational approach for calculating absolute core-electron binding energies. In particular, we demonstrate that accurate absolute binding energies can be obtained from the total energy difference of the ground state and a state with an explicit core hole when exchange and correlation effects are described by a recently developed meta-generalized gradient approximation and relativistic effects are included even for light elements. We carry out calculations for molecules, solids and surface species and find excellent agreement with available experimental measurements. For example, we find a mean absolute error of only 0.16 eV for a reference set of 103 molecular core-electron binding energies. The capability to calculate accurate absolute core-electron binding energies will enable new insights into a wide range of chemical surface processes that are studied by x-ray photoelectron spectroscopy.