In this article we obtain class invariants and cyclotomic unit groups by considering specializations of modular units. We construct these modular units from functional solutions to higher order q-recurrence equations given by Selberg in his work generalizing the Rogers-Ramanujan identities. As a corollary, we provide a new proof of a result of Zagier and Gupta, originally considered by Gauss, r...