  Linear codes with a few weights are very important in coding theory and have
attracted a lot of attention. In this paper, we present a construction of
$q$-ary linear codes from trace and norm functions over finite fields. The
weight distributions of the linear codes are determined in some cases based on
Gauss sums. It is interesting that our construction can produce optimal or
almost optimal codes. Furthermore, we show that our codes can be used to
construct secret sharing schemes with interesting access structures and
strongly regular graphs with new parameters.
