A new mechanism for mesostructure formation of ordered mesoporous carbons (OMCs) was investigated with in situ small-angle X-ray scattering (SAXS) measurements: thermally induced self-assembly. Unlike the well-established evaporation-induced self-assembly (EISA), the structure formation for organic-organic self-assembly of an oligomeric resol precursor and the block-copolymer templates Pluronic P123 and F127 does not occur during evaporation but only by following a thermopolymerization step at temperatures above 100 °C. The systems investigated here were cubic (Im3m), orthorhombic Fmmm) and 2D-hexagonal (plane group p6mm) mesoporous carbon phases in confined environments, as thin films and within the pores of anodic alumina membranes (AAMs), respectively. The thin films were prepared by spin-coating mixtures of the resol precursor and the surfactants in ethanol followed by thermopolymerization of the precursor oligomers. The carbon phases within the pores of AAMs were made by imbibition of the latter solutions followed by solvent evaporation and thermopolymerization within the solid template. This thermopolymerization step was investigated in detail with in situ grazing incidence small-angle X-ray scattering (GISAXS, for films) and in situ SAXS (for AAMs). It was found that the structural evolution strongly depends on the chosen temperature, which controls both the rate of the mesostructure formation and the spatial dimensions of the resulting mesophase. Therefore the process of structure formation differs significantly from the known EISA process and may rather be viewed as thermally induced self-assembly. The complete process of structure formation, template removal, and shrinkage during carbonization up to 1100 °C was monitored in this in situ SAXS study.