Introduction
I have been using VS Code to run and build linux based apps on windows by using VS code's remote wsl feature.
I have found that debugging in visual studio code is not as efficient as in Visual studio 2022.
After some research I found out how you can target wsl2 from visual studio 2022 following this link: Walkthrough: Build and debug C++ with WSL 2 and Visual Studio 2022
This allows you to run linux based programs in c++ on Visual Studio 2022 on windows.
Problem
But running my program (which is using pthreads) Visual Studio gives following error
NOTE: Library of pthread.h is included
/home/appleconda/.vs/Spark_kernelWsl/out/build/linux-debug/../../../Spark_kernelWsl/Spark_kernelWsl.cpp:151: undefined reference to `pthread_create'
My intuition is that how on linux we compile pthreaded program using -pthread maybe visual studio 2022 is not compiling using -pthread
g++ -pthread -o main main.cpp
by default visual studio 2022 is not compiling with -pthread
How can I make my cmakeproject in visual studio 2022 to compile pthreaded programs