Libs needs to be included at the and

Libraries need to be placed at end of the compiler command. Else it won't compile for me.

See: http://stackoverflow.com/questions/9803145/undefined-reference-to-pthread-create