MS Visual Studio C1083 for every project - visual-studio

I just encountered problem with Visual Studio 2013, when I get C1083 for every project/solution. Error I am getting looks like this one (path and name differ from project to project)
Error 1 error C1083: Cannot open source file: 'main.cpp': No such file or directory D:\what\c1xx what
there is only one file, main.cpp containing just
#include <stdio.h>
int main(){
printf("hello world");
while (1);
}
so nothing should be wrong there. Project folder contains
Debug
main.cpp
what.sdf
what.sln
what.vcxproj
what.vcxproj.filters
what I find strange, VisualStudio keeps claiming main.cpp does not exist even when I place absolute path to it in vcxproj instead of just filename.
I'd like to note that VisualStudio was working, stopped without me fiddling with anything and reinstalation nor repair did help.
Any help would be much appreciated.

Related

Visual Studio does not find include files, but paths are correct

For my project, I am using Visual Studio 2015. I have added to my include path the folder $(ProjectDir)Source. In details view of Include Directories, in the list below with Evaluated value, the correct path is listed. When I copy this path using #include "path/file", it finds the file. Or via Start > Run, it opens the path.
In my project I have a .cpp file which includes the file like usual:
#include <file>.
Still, I am receiving the error: Cannot open include file 'file.h' No such file or directory. Error C1083.
I copied an existing solution which had similar includes and adjusted them accordingly. It works now.

Adding external header to Visual Studio project

I have just created a new, empty, console C++ project in Visual Studio 2012. I create one file called main.cpp, with the following code:
#include "myheader.hpp"
int main()
{
return 0;
}
Then, I right-click on Solution Explorer, choose to add an existing item, and then browse to the location of my file myheader.hpp. Once this is added, I see it appears under Solution Items.
Now, I try to build the project, but I get the error:
Error 1 error C1083: Cannot open include file: 'myheader.hpp': No such file or directory
What's going on?
If the header is not in the project directory, you must use a relative path.
Example:
#include "..\..\SomeOtherDir\myheader.hpp"
Another solution may be to add ..\..\SomeOtherDir to the
C++ / General / Additional Include Directories
properties for the project.

c++ -- Visual Studio 2010 Linker Error LNK1104: 'cannot open file Debug\AssemblyInfo.obj' [.obj files are not created at compile time]

After a great deal of searching and head banging, i'm asking this question.
I started a new Windows Forms Application in Visual Studio 2010. Gave it a name and stored it in a location. Nothing added or edited in the same. No changes in the project properties either.
Here is a copy of the Solutions Explorer.
I'm building the empty form and I get the following error.
1>------ Build started: Project: TestProject, Configuration: Debug Win32 ------
1>Build started 27/11/2013 1:35:27 PM.
1>InitializeBuildStatus:
1> Touching "Debug\TestProject.unsuccessfulbuild".
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>CoreResGen:
1> Processing resource file "Form1.resX" into "Debug\TestProject.Form1.resources".
1>LINK : fatal error LNK1104: cannot open file 'Debug\AssemblyInfo.obj'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.41
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Now I have checked every damn page relevant to the error (6 hrs. of googling!!)
Here is a list of the possible errors as suggested by MSDN. Now I'm new to MSVS 10, so I figure out that the .obj file is not present in the Debug Window, but AssemblyInfo.cpp is present. What should I do in the project settings so that the .obj gets compiled and the error goes away.
Update: Still no answers!! I'm amazed how NOBODY is getting this issue. Here is what I have tried soo far and the following happens:
Opened new Visual C++ Windows Forms Application (no modifications!)
Write ABSOLUTELY NO CODE.
Build Project
And the error occurs.
Next
Opened an old solution, where the .obj files were present.
Made a rebuild of the solution.
Same Error.
I look up the solution in the windows explorer. All .obj files are gone(which should happen as a rebuild would clean the .obj files). But what remains are onlt the .log files.
Thus, I have isolated the error that the compilation is not occuring as the linker files are not being created. As a result, the linker error LNK1104 or LNK1181 happen.
Can somebody tell me why is this problem. Has anyone seen this before. Can anyone provide a solution, if possible??
The compiler says there are not modification in any of the files "Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files." So it'll skip the compilation phase (which generates the .obj files).
But the linker needs these files and for some reason they don't exist (at least that's what you claim is happening).
So you can try to force the compilation by doing a clean and than rebuild.
EDIT:
This particular issue can also be caused by specifying a dependency to a lib file that has spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly.
On the Configuration Properties -> Linker -> Input tab of the project’s properties, there is an Additional Dependencies property.
C:\Program Files\<lib> -> "C:\Program Files\<lib>"
This problem got solved long ago.
1>LINK : fatal error LNK1104: cannot open file 'Debug\AssemblyInfo.obj'
1>
1>Build FAILED.
This was happening because the file Debug\AssemblyInfo.objwas simply not being created. This was due an error in the VS registries.
I did a clean, fresh install of windows and VS. This fixed the registry issues, and the file was being created perfectly.
I hope this helps people. Cheers!
I had a similar problem recently and it turned out to be due to the fact that I'd forgotten to unset /P in my compiler settings. Even though it seems like your problem is distinct, we both got the same error message.
When you preprocess to a file, cl stops producing .obj files.

Why Visual Studio cannot find 'tr1/unordered_map?

I want to use google-ctemplate in a project. But if I include the basic file, I get the following error (with Visual Studio C++ 2005):
Error 1 fatal error C1083: Cannot open include file: 'tr1/unordered_map': No such file or directory f:\entwicklung\libraries\ctemplate-0.99\src\ctemplate\template_cache.h 39
I can find the unordered_map.hpp in the boost-directory and the boost-directory is set in the include-path in Visual Studio. How can I solve this problem?
I found out what the problem was. I included the wrong directory from google-ctemplate. Instead of src I have to use src/windows.
But that triggers another Problem, this time from the linker.
As is, you can use:
#include <boost/tr1/unordered_map.hpp>
Alternatively, add your $(boost-directory)/boost/tr1/tr1 to the include path and use:
#include <unordered_map>
See this Header Include Style for more details.
Note: I'm assuming $(boost-directory) is set to something like "C:\boost_1_46_0".
Considering that TR1 was not published until the summer of 2005, I wouldn't be surprised that it isn't present in VS 2005. You might try a more up-to-date version of the compiler!

cmath.h and compile errors

I used to work with math.h without any problem. Now, I use an external library which itself has a file called math.h, but which includes < cmath>.
Adding this library to my project (or even just adding the include directory, without touching the code) now generates tons of errors from < cmath> :
C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2039: 'acosf' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2873: 'acosf' : symbol cannot be used in a using-declaration
C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2039: 'asinf' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 8\VC\include\cmath(18) : error C2873: 'asinf' : symbol cannot be used in a using-declaration
[etc, etc...]
I don't understand why this happens. I am using Visual Studio 2005 and looking on the internet, it seems that this problem is solved under VS 2008. However, I'd like to stay on VS 2005...
Including using namespace std; everywhere, or changing the order of my includes doesn't seem to change anything. Defining _STD_BEGIN solves the error, but produce as many in < xlocinfo>.
How can this be solved?
Same Problem exists in VC 10. I think, that <cmath> includes itself a math.h but insted of the correct one, which is shipped with VC it uses the one which is created in the User-Project (with different content of course).
Solution: Do never use a File named math.h in your Project... (Or correct the std somewhere).
I'm not sure I read your question correctly but it seems odd that a library would ship it's own math.h file.
Perhaps you are suppose to put the parent directory in your include path so that <my_lib/math.h> can be included without conflicting with your compiler <math.h>?
The problem is probably mixing C libraries with C++ conventions. For instance:
#include <math.h>
namespace TEST {
}
This compiles fine, whereas:
namespace TEST {
#include <math.h>
}
This generates a large number of spurious errors.
Just to confuse the issue:
#include <math.h>
namespace TEST {
#include <math.h>
}
This also compiles as it can only be included once (the first time).
Hence also:
#include <math.h>
namespace TEST {
#include "SomethingThatIncludesMath.h"
}
Will work, whereas:
namespace TEST {
#include "SomethingThatIncludesMath.h"
}
Won't.
You can also get similar problems by including C++ headers into a *.c file, rather than a *.cpp file.
I am sure that other similar mixing of C and C++ can lead to similar problems.
(1) According to Microsoft, the C2873 means;
'symbol' : symbol cannot be used in a using-declaration
A using directive is missing a namespace keyword. This causes the compiler to misinterpret the code as a using declaration rather than a using directive.
(2) Also when I had C2873 with C2039 (I tried to merge CEF3 and Cinder), somehow I bypassed the both error by changing Properties->Configuration Properties->C/C++->Code Generation;
Enable Minimal Rebuild: Yes(/Gm), Enable C++ Exception: Yes(/EHsc), Enable Function-Level Linking: empty

Resources