I want to know if possible I can remove or hide this warning
I am using visual studio 2022 in my project. I don't know what's the cause of the warning.
Blockquote 6>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\verrsrc.h(18): warning RC4005: 'VS_VERSION_INFO' : redefinition
OK, try the following. Right-click on your project and select Properties. Go to C++ -> Advanced and change Show Includes as shown below:
This will show you all dependencies in order they are searched when the project is built. Search for verrsrc.h in the output window. You should be able to find a culprit. verrsrc.h should show in at least two places.
Related
I am trying to compile a project, but it looks for includes in the wrong folder or for some other reason cant find winres.h.
I tried adding the path to it (C:\Program Files (x86)\Windows Kits\8.0\Include\um) everywhere but it doesn't work.
My VC++ include derictories path looks like this:
$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;C:\Program Files (x86)\Windows Kits\8.0\Include;
My C/C++ Additional Include Directories path looks like this:
../../include;../../src/libpocketsphinx;../../../sphinxbase/include;../../../sphinxbase/include/win32;C:\Program Files (x86)\Windows Kits\8.0\Include;%(AdditionalIncludeDirectories)
The error is:
pocketsphinx.rc(10): fatal error RC1015: cannot open include file 'winres.h'.
How do I change the include path?
I would post the images illustrating but I do not have enough reputation points. To change the includes of a project, follow these steps:
1) Open visual studio.
2) Open your projects.
3) Open the drop down menu by right-clicking your project in the solution explorer.
4) Click on Properties.
Now there are two places to change includes:
1) Click on VC++ Includes.
2) Add an includes directory to the field "Include Directories".
Or
1) Click on C/C++>General.
2) Add an includes director to the field "Additional Include Directories".
If this is just for the current project, use the second means of adding. Then of course, click OK or Apply.
For future reference, I suggest going through some of the VS tutorials. This would be covered there.
I have a bunch of these errors and am at a dead end.
Found plenty of answers on google but unfortunately none of them work
I am using Visual Studio 2012.
All the files it says is cant find are on my computer in this folder
C:\Program Files\Microsoft Visual Studio 11.0\VC\include
Even when I right click on the include statement and click on 'Open Document ' it takes me to the document, so it is clearly there and can be seen
I tried adding the directory to the 'Additional Directories' field in options too but did not solve it.
If I use the include statement with the full path like so :
#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>
Then is works but if the math.h file has any include statements I need to add the path to them as well and so on.
Any Idea what is happening and what else I can try?
EDIT: Going to try and create a new project from scratch and see if that helps. It is possible I touched a settings I shouldn't have
Right-click your project, go to Properties, then go to VC++ Directories and open the editor for Include Directories. There should be a tick box labelled "Inherit from parent or project defaults". You will see that Visual Studio includes some predefined directories.
If the box is already ticked and Visual Studio isn't finding the directories then try adding these directories yourself:
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSDK_IncludePath)
The following is not correct in multiple ways:
#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>
\... begins a so called escape sequence, therefore you are putting the special tokens \P, \M, \V, \i and \m into the string, but unlike for example \n, which denotes a the newline character, these do not exist as valid escape sequences. This can be fixed by using forward slash consistently:
#include <C:/Program Files/Microsoft Visual Studio 11.0/VC/include/math.h>
However, math.h is a standard header. For standard headers, you don't write the full path. For non-standard headers, you add the include-path to the project setup, and don't write the full path neither.
#include <math.h>
Then: You are in C++, not in C. The C++ equivalents of the C-headers usually have the .h extension removed, and a c appended to the front:
#include <cmath>
I've just had the same problem, and my solution was simply to place the filename in quotes instead of angle brackets.
So, instead of < dog.h> , "dog.h" solved the "file not found" problem.
This is a bug in Visual Studio that Micosoft has set to "Closed - not a bug" see the link
https://developercommunity.visualstudio.com/content/problem/311530/win10-sdk-broken.html
I searched my PC for math.h and found it in a sub folder under "Program Files\Unity", i.e. Visual Studio did not install it. I seem to have the reverse midas touch this weekend, everything I touch turns to crap.
Retarget the project under the solution properties.
Building with/ Using VS2010
Platform SDK (Microsoft Windows SDK v7.1) installed.
When i try to build the Sample LSP (located in C:\Program Files\Microsoft Platform SDK\Samples\NetDS\WinSock\LSP)
!--BEGIN RESOLVED--!
I get 16 of the same two errors below.
Error 1 error C1083: Cannot open include file: 'nt.h': No such file or directory c:\program files\microsoft sdks\windows\v7.1\samples\netds\winsock\lsp\nonifslsp\lspdef.h 22 1 LSP
Error 7 error C1083: Cannot open include file: 'lspcommon.h': No such file or directory c:\program files\microsoft sdks\windows\v7.1\samples\netds\winsock\lsp\install\instlsp.h 35 1 LSP
When i added the source code of this sample to VS, i use File>New ProjectFrom Existing Code.
Once i do that, VS starts importing all the Platform SDK include files. I was reading elsewhere that not having the includes from PSDK would cause problems, but this doesnt seem to be the case here.
!--END RESOLVED--!
I now run into 3 more errors after fixing the above problem:
Error 1 error LNK2005: "struct _GUID gProviderGuid" (?gProviderGuid##3U_GUID##A) already defined in lspguid.obj C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp\instlsp.obj LSP
Error 6 error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409 C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp\CVTRES LSP
Error 7 error LNK1123: failure during conversion to COFF: file invalid or corrupt C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp\LINK LSP
I have not changed any of the contents/files in the LSP sample.
Currently I'm just trying to build it.
Any insight on this would be helpful.
Thanks.
The file lspcommon.h is part of the LSP sample, you should be able to find it in the 'common' subfolder. (C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp\common)
If you double click on one of your errors the editor will open focused on the line that's giving problems. Do that for lspdef.h line 22 and you'll see the code looks like this...
#ifndef _PSDK_BLD
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#endif
That means, the nt.h file (and two others) is only included if the macro _PSDK_BLD is not defined. Look a little lower at line 35 and you'll see the code looks like this...
#ifndef _PSDK_BLD
#include <lspcommon.h>
#else
#include "..\common\lspcommon.h"
#endif
In this case, if the macro is not defined the code includes the file lspcommon.h, but if the macro is defined then the code includes the file lspcommon.h from the common foider.
It seems likely then that your problems are happening because _PSDK_BLD is not defined. From the style of the #ifdef it doesn't look like the macro has to be defined to any specific value, just defined.
In Visual Studio, go to Project Properties, drill down to C/C++ and then Preprocessor. Then find the preprocessor definitions line and click on the value. Now select edit and add _PSDK_BLD to the list of preprocessor definitions.
Watch out for that leading underscore, and remember to make the change for Debug and Release configurations (and for all the platforms you may have defined)
The error LNK2005 means that the linker found two definitions for the object it is trying to link - which is a problem because there's no way for the linker to be able to tell which of the two definitions it should use.
In this particular case, the object the linker is trying to resolve is "struct _GUID gProviderGuid". If you look in the files instlsp.h, lspdef.h (both of them) and lspcommon.h you'll see code that looks like this
extern GUID gProviderGuid;
That declares an external variable called gProviderGuid of type GUID (which is a struct). The linker has to resolve that external reference in any file that included one of those header files and then made a reference to gProviderGuid.
From the "already defined in lspguid.obj" part of the error we know the linker has looked inside the file lspguid.obj and found a definition of gProviderGuid. Sure enough, if we look inside lspguid.cpp we can see a definition of gProviderGuid with a value starting 0xc5fabbd0.
From the "C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp\instlsp.obj" part of the same error we know that the linker has also looked inside the file instlsp.obj and found a second definition of gProviderGuid. If we look inside intlsp.cpp we can see another definition of gProviderGuid (this time without any value).
The problem then is that the linker is looking in both lspguid.obj and intlsp.obj and finding conflicting definitions of gProviderGuid.
Those two files should not be part of the same build so we shouldn't expect a single run of the linker to read them both at the same time.
The LSP project is made up of four parts: lspcommon which is used to generate the static library lspcommon.lib; ifslsp which is used to generate the file ifslsp.dll; nonifslsp which is used to generate the file nonifslsp.dll and install which is used to generate the file Instlsp.exe. See the readme.txt file in lsp and the makefile files in the various folders for more details.
If you are going to build LSP inside Visual Studio, you really need four different projects in your solution, one each for lspcommon, ifslsp, nonifslsp and install.
Add this define to your build: _PSDK_BLD
It would solve your problem
Try changing #include <nt.h> to #include <winnt.h> and see if it builds.
I've just been beaten (rather hardly) on the head by some non-trivial warning from Visual Studio 2010 (C++).
The compilation gave the following output:
1 Debug\is.obj : warning LNK4042: object specified more than once; extras ignored
1 Debug\make.obj : warning LNK4042: object specified more than once; extras ignored
1 Debug\view.obj : warning LNK4042: object specified more than once; extras ignored
1 identity.obj : error LNK2019: unresolved external symbol void __cdecl
test::identity::view(void) (?view#identity#test##YAXXZ) referenced in function void __cdecl test::identity::identity(void) (?identity#0test##YAXXZ)
1 identity.obj : error LNK2019: unresolved external symbol void __cdecl test::identity::make(void) (?make#identity#test##YAXXZ) referenced in function void __cdecl test::identity::identity(void) (?identity#0test##YAXXZ)
1 range.obj : error LNK2019: unresolved external symbol void __cdecl test::range::is(void) (?is#range#test##YAXXZ) referenced in function void __cdecl test::range::range(void) (?range#0test##YAXXZ)
Linker errors are always a pain to debug... but there were unresolved references, and so I checked... but the source is well-formed... and finally it hit me:
My folder hierarchy looks like so:
src/
identity/
is.cpp
make.cpp
view.cpp
range/
is.cpp
make.cpp
view.cpp
and so does the hierarchy in the Solution (I always set it up so that it mimicks the "real" folder structure).
And the diagnostic outputs:
Debug\is.obj
Debug\make.obj
Debug\view.obj
Along with a warning which says that the .obj has been passed twice to the linker and that one will be ignored.
Search no more: Visual has neatly flatten my folder hierarchy, and therefore is unable to neatly compile the source.
At the moment, I am simply thinking of renaming the files, that should cover the issue...
... but is there a way to have Visual Studio NOT flatten the file hierarchy ?
I had a similar problem with linker warning LNK4042: object specified more than once; extras ignored. In my case Visual Studio was trying to compile both header and source files with the same name - MyClass.h and MyClass.cpp. It happened because I renamed .cpp file to .h and Visual Studio got confused. I noticed the problem by looking at the compiler logs in the Debug directory. To resolve just remove .h file from the project then add it again.
Just wanted to cross post what I believe to be the answer, if you open the properties for the entire project, and the change the value under C/C++ -> Output Files -> "Object File Name" to be the following:
$(IntDir)/%(RelativeDir)/
Under VS 2010, I believe this will disambiguate all of the object files (as I believe windows won't let you under any crazy circumstances have two files with the same names in the same directory). Please also check out the details here.
Right-click the .cpp file in the Solution Explorer window, Properties, C/C++, Output Files, Object File Name setting. The default is $(IntDir)\, that's what is doing the flattening. All the .obj file will go into $(IntDir), the "Debug" directory in the debug configuration.
You can change the setting, say $(IntDir)\is2.obj. Or select all the files from one group (use Shift+Click) and change the setting to, say, $(IntDir)\identity\
Or you can change the .cpp filename so that .obj files don't overwrite each other. Having files with the exact same name in two directories is a bit odd.
Or you can create multiple projects, creating, say, .lib projects for the files in identity and range. Commonly done in makefile projects for example. That does however make managing the compile and link settings more of a hassle unless you use project property sheets.
Right click on header file -> Property -> ItemType (select C/C++ Header). Do the same with Cpp file but select C/C++ Compiler (it's work for me)
Alternatively to deleting and making a new file you can change the compile/include settings.
Go to your project.vcxproj file, open it with an editor, find the html like line <ItemGroup>.
It should look something like:
<ItemGroup>
<ClCompile Include="implementation.cpp" />
</ItemGroup>
and
<ItemGroup>
<ClInclude Include="declaration.hpp" />
</ItemGroup>`
Assuming your implementation files are .cpp and your declarations are .hpp. Make sure your all your implementation files are listed between the first section if you have more then one and likewise for the second section for multiple declaration files.
I had this problem with stdafx.cpp. Somehow stdafx.cpp got duplicated, so there was a second StdAfx.cpp (mind the different case).
After I removed the StdAfx.cpp everything worked fine!
Using VS 2010.
I use $(IntDir)\%(Directory)\ under C/C++ -> Output Files -> "Object File Name".
I used to have in the same project .c and .cpp files with the same filenames. The files were in folders all over the place and the solutions provided by others created a mess, and folder hell (in my case). Even Release builds would overwrite Debug builds!
A good (not perfect) solution would be to use $(ParentName), but for some reason beyond anyone's grasp it has been removed from later versions of Visual Studio (2015+).
What I use succesfully now is:
$(IntDir)%(Filename)%(Extension).obj
which at least separates .c built object files from .cpp.
I'd like to point out one possible reason for why the ItemType of a .h file would change from C/C++ header to C/C++ compiler:
In the Solution Explorer window of VS (2019 here), right click the project name, choose Add -> New Item;
Select the C++ File (.cpp) template, but type something.h in the name input area, then click OK to add it;
Then you'll encounter the LNK4042 warning if the something.h file be included within more than one .cpp files.
I just overcame a similar error message, and lots more with the procedure below. Symptom: one linker error for every invocation of every function defined in a particular header, plus one at the end of output for every function defined in the header.
Then I remembered that when I had originally created this header, I accidentally had selected "add->new item->c++ file" and though I named it 'whatever.h', it seems Visual Studio considered them both the same kinds of files because of the incorrect action I used to add one. Examining the build output logs made this obvious.
SOLUTION (Using VS Community 2019)
Back up project first (just to be safe).
Right-click the offending header file and select "Exclude from project" (this will not delete them; the VS project will just ignore them).
Do same for the matching .c or .cpp file.
Do Build->Clean on project
Do Build->Rebuild on project
-- there of course will be errors---
Right-click Header Files->Add->Existing Item, then select the .h file
Right-click Source Files->Add->Existing Item, the select the .c or .cpp file
Do Build->Rebuild on project.
This completely cleaned it up for me, relieving me of many irritating linker errors including LNK4042 from the title of this question.
I resolved it changing filenames in my project. There was two files named main.c and main.cpp. I changed one of them and worked.
I'm trying to integrate two projects, and to that end am including header files from one into the other. I'm using visual studio 2008 express.
The line
int E4407B_PPM(int &);
is throwing errors in the new project, but the original project compiles just fine.
The error I'm getting:
error C2143: syntax error : missing ')' before '&'
Any ideas?
Edit: I ended up removing the lines that took parameters in by reference, and just insured that all functions were declared before they were used in the actual source file. I guess it was a C++/C thing.
You are probably building the second project (or at least the source file) as straight C. Make sure the file has a .cpp extension or that you are forcing a C++ compile (you can use the /TP compile option to do that).
Edit You can specify it for a single file: Right click on the file in the solution explorer and select Properties. Click on the Advanced option under C/C++. Choose "Compile as C++ Code (/TP)" (second option in the page in my version of Visual Studio).