How to create a binary executable file from a .cpp file in window PC?

Using MAC computer, I created a file called “task.so” by typing the following command in RStudio Terminal:

R CMD SHLIB task.cpp

My R code calls this "task.so" file. However, the “task.so” file seems to work only in MAC computer but not in Window PC. How could I create a similar binary executable file that functions like file “task.so” that can run in Window PR Rstudio?

Do you have a C++ toolchain (make, compiler, linker) installed?

The SHLIB depends on the compiler installed to the system to build libraries.

Try Rtools

It appears to be a one stop shop for the tools required to build shared libraries or R itself from source.

I have downloaded Rtools in window. I have no experience in Rtools. How to use it to create a binary executable file so that RStudio can run it?