Reputation: 87
I have searched for hours online trying to find a solution. I'm new to C++, however I've compiled quite a few programs and never had any trouble until last night.
I'm using the Microsoft VS command prompt. I've tried this on 2010, 12, and 13, and get the same error... as well as on 2 different computer systems. I thought it may be a code issue, however, I just typed up a simple program that I know will work, yet I get the same error. I'm running Windows 8 64 bit
From the command prompt I enter cl C:\Users\David\Desktop\1\simplecpp.cpp
and get the following error:
C:\Users\David\Desktop\1\simplecpp.cpp : fatal error C1083: Cannot open compiler generated file: 'simplecpp.obj': Permission denied
I can get the programs to compile if I run as Administrator (what I read on another post) However, there is no output. It doesn't save the object or program files. I have also checked permissions, and everything is correct.
Neither computer has had anything changed, both do use ad-aware, however, I disabled that and tried just in case something was interfering, but still it doesn't work. I also turned off my firewall and tried. I find it odd that both of my computers at the same time are experiencing the same issue?
Upvotes: 3
Views: 9921
Reputation: 1
I use VS2019 meet this problem, and finally I found out the reason.
[MyClass].cpp
to my project, VS will auto add CPP to project's .vcxproj.filter
,ClCompile
block.[MyClass].h
.By do this, VS doesn't re-organize all files in .vcxproj.filters
except path, so HEADER file is still in ClCompile
block, this cause the problem.
To solve, simple delete the file from project and re-add it
Upvotes: 0
Reputation: 1
You also can run into this issue when you attempt to build a release. My old release was still in the release folder and I made one of the files hidden. It gave me this error and I couldn't figure out why but, if you make that file unhidden again it, resolves it.
Upvotes: 0
Reputation: 165
I needed to set msdev.exe located in C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin to run in Win XP, SP3 compatibility mode for all users to fix this issue. It was already set to run as admin for all users.
Upvotes: 0
Reputation: 87
Ok, I found out what the problem was. I don't know how it happened, but somehow, my Microsoft Visual Studio 10.0 folder permissions for my master account got reset on both of my computers and I didn't have permissions to modify any files. This is the case for other versions I had installed as well.
Possibly a windows update issue? Anyhow, I reset permissions to allow full access, and all is working now!
If anyone else comes across this and is having the same issue, just navigate to your Microsoft Visual Studio 10.0 folder "...Program Files (x86)\Microsoft Visual Studio 10.0" > right click and go to Properties > Click security tab > Click Edit, then the affected user and check full control.
It is, however, saving my project files to the root Microsoft Visual Studio 10.0 folder now.
Thanks
Upvotes: 4
Reputation: 4174
Look for other instances of Visual Studio which may have that file open still. Close them if you find them. If all else fails, reboot the machine -- Windows is very fussy about open files!
Upvotes: 0