1

I just installed visual studio, (not new to coding) and I keep getting an error that goes like "error: unable to open file C:user...main.obj Error code = 0x80070002" an Image of the error this error shows up whenever there is something wrong with my code like for example if i do:

#include <iostream>

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

everything runs normal, but if I make a mistake say:

#include <iostream>

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

I get the error, it's so annoying I don't want to get that error every time there is something wrong with my code the error list bar is enough, what do I do ?

4
  • 1
    Never seen that error before. Have you done something weird like put your object files under source code control?
    – john
    Mar 26, 2020 at 12:52
  • if you google 0x80070002 there are some hits that talk about an incomplete windows update.
    – drescherjm
    Mar 26, 2020 at 13:01
  • You may want to try a clean build. Even delete the Debug folder completely. Or does this happen on any project?
    – drescherjm
    Mar 26, 2020 at 13:02
  • check if Configuration Properties -> Linker -> Debugging -> Generate Debug Info is enabled. Mar 26, 2020 at 13:25

2 Answers 2

0

Could you please tell us what version of Visual Studio are you using?

If you are using vs2017 or later, I suggest you could try to use /DEBUG:FULL property in "Linker/Debugging/Generate Debug Info.

enter image description here

I suggest you could refer to the Doc:

When you specify /DEBUG with no additional options, the linker defaults to /DEBUG:FULL for command line and make file builds, for release builds in the Visual Studio IDE, and for both debug and release builds in Visual Studio 2015 and earlier versions. Beginning in Visual Studio 2017, the build system in the IDE defaults to /DEBUG:FASTLINK when you specify the /DEBUG option for debug builds. Other defaults are unchanged to maintain backward compatibility.

0

Rebuild the program in a different disk or reinstall the VS could be the final solution I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.