Added -pthread to make multithreading work.