You must specify the Motif library on the command line before other X libraries.
WRONG:
cc .... -lXt -lXm
cc .... -lXm -lXt
PREV INDEX NEXT