A compound is anything composed of two or more separate elements.
O2 and H2 are a singular elements, and a chain of carbon atoms is multiple of the same element, so these are not considered compounds.
Sodium chloride is sodium and chlorine, and water is oxygen and hydrogen. Glucose is a compound of sugar, and organic biological (or biomolecules) are made up of carbon and hydrogen, so these are all considered compounds