Galactic cosmic rays are believed to be accelerated at supernova remnant shocks. This idea is very popular but we still miss a conclusive evidence of its validity. In this talk, I will give a general and not-too-technical review on the connections between gamma-ray astronomy and cosmic-ray physics. In particular, I will discuss how recent gamma-ray observations of supernova remnants and molecular clouds can help us in understanding the origin of galactic cosmic rays.