I currently have the power spectrum (in dB) of a signal through which I obtained the fundamental frequencies and amplitudes. My question is: how to generate a time domain signal using these amplitudes and frequencies (using C++ for example)?
No way. You cannot recover a time domain signal from its fundamental frequency. Although, it is not clear what does a plural means here, "the fundamental frequencies and amplitudes", so maybe I am not quite understanding you.
Also, the power spectral density (PSD) alone, whether in dB or else, is not sufficient to recover a time domain signal: you need an energy spectral density for this deed. Citing a Wikipedia article:
The above definition of energy spectral density is suitable for transients (pulse-like signals) whose energy is concentrated around one time window; then the Fourier transforms of the signals generally exist.
The Fourier transform of the signal is what you need in order to recover a time domain signal, because the PSD lacks the phase information. Moreover, a periodogram, if it is what you hint by mentioning "fundamental frequency", does embrace averaging, either in time or frequency, which makes the periodogram still less suitable for a time domain signal recovery.
Although it seems that your question is about PSD, you may be interested in retrieving phase information from energy spectral density. There is a number of techniques, the classical one is use of the Kramers Kronig relations for analytical signal. See also a review of three techniques (including KK) used in optical measurements, in Deep learning as phase retrieval tool for CARS spectra. Section 2.2 of this article presents the formula for deducing the phase from the squared modulus (formula 15), with stipulations made about a noise and discrete nature of measurements.
A word about implementation: in order to write a C++ implementation, you need a thorough understanding of signal processing algorithms. Searching github.com for open source implementations of phase retrieval techniques, I've found a Python implementation of phase retrieval for Raman spectroscopy, with Jupyter notebook, explaining the implementation details, see CRIKit2: Hyperspectral imaging toolkit. You may browse this presentation, at least out of curiosity.