Texture coordinates tell OpenGL which area of a given flat image is to be mapped to the defined triangles. There's no way to figure that out automatically. Normally artists will define texture coordinate mappins while creating the 3D model.
Recently Disney Animation developed a new texturing scheme called PTex where each triangle holds its very own texture; apart from relieving the artist caring about texture coordinates it also eliminates the mathematical problems when trying to map a topologically flat image onto geometries of different topology.