Abstract: We prove the equivalence of two conjectural constructions of unramified cuspidal automorphic functions on the adelic group associated to an irreducible -adic local system of rank on an algebraic curve over a finite field. The existence of such a function is predicted by the Langlands conjecture. The first construction, which was proposed by Shalika and Piatetski-Shapiro following Weil and Jacquet-Langlands (), is based on considering the Whittaker function. The second construction, which was proposed recently by Laumon following Drinfeld () and Deligne (), is geometric: the automorphic function is obtained via Grothendieck's ``faisceaux-fonctions'' correspondence from a complex of sheaves on an algebraic stack. Our proof of their equivalence is based on a local result about the spherical Hecke algebra, which we prove for an arbitrary reductive group. We also discuss a geometric interpretation of this result.