Errors with libtorch (#include <torch/script.h>)

I’m trying to use ‘libtorch’ for the first time.
I set the C/C++>General>‘Additional Include Directories’, as well as the linker’s ‘Additional Library Directories’ and ‘Additional Dependencies’.
I just added #include <torch/script.h> to my .cpp file, and tried to build to make sure everything is ok, but I got the following errors:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2872	'nullopt': ambiguous symbol	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\DeviceGuard.h	26	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2446	':': no conversion from 'const std::nullopt_t' to 'c10::optional<c10::Device>'	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\DeviceGuard.h	26	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2872	'optional': ambiguous symbol	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\ops\from_blob.h	35	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2872	'optional': ambiguous symbol	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\ops\from_blob.h	54	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2872	'optional': ambiguous symbol	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\ops\from_blob.h	83	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2872	'optional': ambiguous symbol	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\ops\from_blob.h	86	

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2664	'at::TensorMaker &at::TensorMaker::target_device(std::optional<c10::Device>) noexcept': cannot convert argument 1 from 'const c10::optional<c10::Device>' to 'std::optional<c10::Device>'	Road_Defects_Detector	C:\libtorch-win-shared-with-deps-1.12.0+cu116\libtorch\include\ATen\ops\from_blob.h	105