How do I find the generator polynomial for a q-ary cyclic code. I know that for a binary cyclic code, a polynomial that divides $x^n - 1$ can be considered as a generator polynomial (e.g. $1 + x + x^3$ divides $x^7 - 1$ and thus $g(x) = 1 + x + x^3$.
But for non-binary cases I am unsure what is a necessary and sufficient condition to find a generator polynomial. Can someone please give an example. I know that for RS codes $g(x) = (x - a_1)(x - a_2)$. But are there other codes as well ?
Also, if $q = 2^m$, then does this constitute as a special case with additional properties?