Link with threads (needed for raspberry pi).
Fix gcc compile warnings.