'enabling pthread on vscode using code runner extension on linux wsl?

I have encountered an error on Linux while using Posix thread with Code runner on VS Code and encountered an error of undefined reference to pthread_create();



Solution 1:[1]

To fix it please add -pthread argument in code runner settings.json:

    "cpp": "cd $dir && g++ $fileName -pthread -o $fileNameWithoutExt && 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1