0

I have a C++ Project in Visual Studio 2022 (Windows 11) that is put together using CMake. I understand that the difference here is, that my project is not a Solution but rather just folders with code and the CMake tells it how to compile it?

But my problem is, that it doesn't seem to find C's standard libraries and shows error "cannot open sourcefile".

Screenshot

The error is definitely not in the project, since it runs just fine on my laptop, just not on the PC I want it to run on.

How can I tell it where these libraries are? Where are they located even? Any help would be greatly appreciated and I can share more files on request.

Things I have tried:

  • Going to properties and choose the correct Windows SDK Version - The properties are empty
  • Comparing every variable of the CMake Settings with the ones on my laptop where it works
  • completely reinstalling Visual Studio (yes I did that)
  • looking through lots of StackOverflow questions but none of them describe my problem
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
alex.zxg
  • 11
  • 3
  • Googling for "cannot find source file ctype.h" reveals (among others) [this question](https://stackoverflow.com/questions/47051867/fatal-error-c1083-cannot-open-include-file-ctype-h-no-such-file-or-director) and [that one](https://stackoverflow.com/questions/71035431/visual-studio-2022-cannot-open-include-file-ctype-h). Both of them suggest to install Universal CRT SDK component in Visual Studio. Have you checked that given component is installed on your machine? – Tsyvarev Dec 22 '22 at 09:19
  • In my experience using VS to `Open > CMake...` sometimes runs into these issues, but it's also possible to generate a solution based on a cmake project which shouldn't have those issues; Assuming VS 2022 is the default generator and you want to target x64, `cmake -A x64 -S source_dir -B build64_dir` should create a solution which can be opened via `cmake --open build64_dir` (assuming VS 2022 is the program associated with `.sln` files). – fabian Dec 22 '22 at 11:04
  • Check your folder `C:\Program Files (x86)\Windows Kits\10\Include\your sdk version...`. Are there std header files? Did you install C++ workload in visual stdio? – Minxin Yu - MSFT Dec 23 '22 at 03:10

0 Answers0