The invention relates to a process for obtaining compounds derived from tetrahydro-β-carboline, specifically tadalafil and intermediate products from the synthesis, comprising the reaction between piperonal and an alkyl ester of D-tryptophan as a salt, and in the absence of any other component, followed by haloacetylation and a final cyclization with methylamine.