"Error C1083: Cannot open source file" Shouldn't Be Looking For The File At All
I was trying to
#include a cpp file with some functions so I can use that cpp file later with other projects. It gave me an 'already defined in .obj' error and since then that .cpp file was like binded with my project. (I understood that's not the way, the answer here helped me with the already defined)
If I exclude the .cpp file from the project, remove it from the directory and remove the
#include line it still looks for it:
c1xx : fatal error C1083: Cannot open source file: 'std.cpp': No such file or directory
Outputs for D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\CBMAIN.CPP|D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\STD.CPP: (TaskId:15)
It shouldn't be looking for the std.cpp at all, I removed it! So is there a way I can reset the project and recompile so that the program doesn't look for it? I already tried Rebuild and Clear -> Build Project
When I ran across a similar problem with VS Express, I wound up having to open up the the .vcxproj file (which is just XML), and remove the offending < ClInclude Include="FILEPATHANDNAME" > tags.
OK, I have no idea how I did it but I'm still going to try to write what I did.
- Save all and Close solution
- Open the .vcxproj file (not .sln)
- Build -> Clean [Project Name]
- Save all and Close
- Open the .sln file again.
- Build -> Project Only -> Clean Only [Project Name]
- Build -> Project Only -> Build Only [Project Name]
That's exactly what I did and worked for me. I think the main thing to do is clean, save, close, open, build, but I'm not sure.
In Solution Explorer you can select/deselect option "Show All Files". Try both options and make sure excluded file is not included in project for both of them.
That's what I had: I used "Show All Files" option (so you can see all the files in project directories). I excluded one of my .cpp files from project. However, it behaved as this file is in project.
That's how I managed to fix it: I switched "Show All Files" off and saw this file still belongs to project! So I excluded this file once again.
As I see, that's a known issue.
This worked for me, hope it will be useful for someone else.
Many of the solutions here will not work
- Open the vxproj file that is giving you trouble in a text editor.
- remove all references to the file it cannot find.
Try to verbose builder output to see exact steps of what's going on. I suppose, you use Visual Studio, right?
- Go to menu "Tools -> Options"
- In options dialog, select "Projects and Solutions -> Build and Run"
- Change current mode of "MSBuild project build output verbosity" from "Minimal" to something like "Diagnostics" or "Detailed".
- Rebuild your project and investigate Output windows
Builder dump should shed more light on your current settings (I suspect you have more references to that file than you expect)