Added -D_REENTRANT, fixed more warnings adding missing library flags.