Add a check for -lpthread.
Create Release and Debug directories if they are not present.

Otherwise, build fails if these directories do not exist.