1

I've been using visual studio for my unreal projects for some time now. But when i try to code something in vs i get the error "cannot open source file". I have a very basic c++ code;

#include <iostream>

int main()
{
    std::cout << "Hello World!\n";
}

when i debug this code i get the error that almost every header file(435 header files) like float.h, string.h, time.h etc. cannot open.

enter image description here

When i try compiling the code using gcc i get another error but when i use g++ i get no error.

enter image description here

So i'm assuming i need to change debug options of visual studio. I've tried buy i couldn't figure that out. How can i make visual studio run the code properly?

yesil
  • 58
  • 1
  • 8
  • Perhaps you are using the wrong compiler? you say that you used gcc to compile a C++ file but gcc is used to compile C files only maybe check your configuration? – Mintybits Jul 24 '22 at 06:01
  • C code for the most part is valid c++ code but not vice versa – Mintybits Jul 24 '22 at 06:01
  • Check the File extension on your main file – Mintybits Jul 24 '22 at 06:06
  • You probably need to change the windows sdl setting, it's probably set to a sdk that isn't installed – Alan Birtles Jul 24 '22 at 06:20
  • 1
    Project/Properties/General/Windows SDK Version. What does that say? – john Jul 24 '22 at 06:22
  • @john Windows SDK Version: 10.0.19041.0 – yesil Jul 24 '22 at 06:38
  • @Mintybits i don't know what to check in configurations. I've tried different configurations but still getting the same error. – yesil Jul 24 '22 at 06:43
  • 1
    @yesil Mine says Visual Studio 2022 (v143). I also have the option Visual Studio 2019 (v142). Do you have either of those versions available? What version of Visual Studio are you using? Have you installed any standalone versions of the Windows SDK? – john Jul 24 '22 at 06:48
  • @john there is 2 option for sdk 10.0 and 10.0.19041.0 or inherit from parent project. i'm using visual studio community 2022. I don't think i installed any standalone windows sdk. – yesil Jul 24 '22 at 07:21
  • i uninstall the visual studio and re-install it but still the same error. i don't understand i can use g++ to compile, i also have qt creator which is works fine with c++ but visual studio raise this error even efter re-install – yesil Jul 24 '22 at 07:23
  • 1
    @yesil 10.0.19041.0 is the correct version I think. But maybe you don't have it installed. Start the Visual Studio Installer, click Modify and check if the Windows 10 SDK is installed (it's under 'Desktop development with C++'). If that doesn't help try looking at the linked duplicates. You are certainly not the only person that has had this problem. – john Jul 24 '22 at 07:29
  • @john i've clicked modify and yes Windows 10 SDK is installed. I gave up, i'll continue using qt creator :( Thanks for your help. – yesil Jul 24 '22 at 07:34

0 Answers0