Solar photovoltaic integration into buildings provides an effective and attractive method to decrease fossil energy consumption and reduce greenhouse gases emission. This study proposes a flexible photovoltaic integrated building cooling system with electricity and ice storages to address the challenges posed by the instability of solar energy and the integration and coordination of multiple components. Uncertainties in solar irradiance, ambient temperature, and cooling load are characterized using a scenario analysis method that combines Latin Hypercube Sampling and the K-Means++ algorithm. Then, aiming to achieve the minimal total cost, including investment, operational, and CO2 emission costs, a two-layer stochastic optimization model is developed to simultaneously determine the optimal capacities and operational strategies for each device. Genetic algorithm and mixed integer linear programming are, respectively, used to solve the two-layer optimization problem. The comparisons between optimum schemes with and without CO2 emission cost demonstrates that when the base chiller’s capacities are 1179 kW and 1081 kW in cases 1 and 2 respectively, it can independently meet 72.37 % and 61.27 % of the cooling load demand throughout the cooling season. In addition, the optimal capacity of photovoltaics, considering CO2 emission, increases by 109.7 %, and its penetration rate reaches 18.3 %, which is 9.7 % higher than the optimal scheme not considering CO2 emission. However, the annualized investment cost increases by 52.3 %. The developed methods provide effective tools for the system design and operation management of solar energy integrated building cooling system.