Linear codes with few weights have applications in secrete sharing, authentication codes, association schemes, and strongly regular graphs. In this paper, a construction of q-ary linear codes with few weights employing general quadratic forms over the finite field F q is proposed, where q is an odd prime power. This generalizes some earlier constructions of p-ary linear codes from quadratic bent functions over the prime field F p , where p is an odd prime. The complete weight enumerators of the resultant q-ary linear codes are also determined.Mathematics Subject Classification (2010) 94A24 · 94B35 · 94B15 · 94A55 Cuiling Fan