visual studio unable to find assert.h

Viewed 12378

I'm a first year at uni and I just got my new laptop. I downloaded Visual Studio 2017 and pulled my solution repo. However, I'm having some issues because it appears that a lot of the files I had on my previous computer were not downloaded in the installation of VS. My university wifi is slow and I don't want to re-download if I don't have to. I followed the previous steps I took to download VS 2017 on my old computer. Yet, I'm getting errors like:

  • cannot open source file "assert.h"
  • cannot open source file "errno.h"
  • cannot open source file "float.h"
  • cannot open source file "corecrt.h"
  • cannot open source file "stddef.h"
  • cannot open source file "stdio.h"

(among 20+ others)

If I right-click and choose the "Open document" on the line with the error, I get the message: File '_______.h' not found in current source file's directory or in build system path

However, if I go to my include paths, I can find files like:

  • cassert.h
  • cerrno.h
  • ostream.h

but none of the ones that I'm told are missing.

Mainly, I'm wondering if there is a directory with this files I just need to add to the include directory or whether I just need to admit defeat and reinstall.

Thanks for the help, I welcome editing as I'm sure I've messed things up. I'm new to this.

Cheers,

Caleb

3 Answers

Using VS2017 I was able to resolve this same issue by:

  1. Right click on solution
  2. Selecting 'Retarget Solution'
  3. Selecting an SDK from the Windows SDK Version dropdown
  4. Clicking OK button

enter image description here

Your Visual Studio 2017 installation is probably missing the C packages (they are not automatically included with the Desktop development with C++ workload).

To install it, start the Visual Studio Installer, go to Individual components, and check Windows Universal C Runtime:

enter image description here

I think this component is also automatically marked for installation when adding the Linux development with C++ workload.

I solved the problem by uninstalling my original installation of Visual Studio (2019 version), then reinstalling and including the workload Desktop Development with C++.

In contrast to the above solutions, I did not need (and it did not help) to add the Windows Universal C Runtime.

Related