xxx\vc\atlmfc\include\atlcore.h(638): error C2039: “SetDefaultDllDirectories”: is not a member of "global namespace"
#ifndef _USING_V110_SDK71_
// the LOAD_LIBRARY_SEARCH_SYSTEM32 flag for LoadLibraryExW is only supported if the DLL-preload fixes are installed, so
// use LoadLibraryExW only if SetDefaultDllDirectories is available (only on Win8, or with KB2533623 on Vista and Win7)...
IFDYNAMICGETCACHEDFUNCTION(L"kernel32.dll", SetDefaultDllDirectories, pfSetDefaultDllDirectories)
{
return(::LoadLibraryExW(pszLibrary, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32));
}
#endif
the functions in it are all not realized by VS
so how do I solve this problem?
is there something wrong with the libray?I run this program in VS2012
You have to make sure "_USING_V110_SDK71_" is defined in your project properties. Visual Studio automatically defines this for you. It normally doesn't "show up" because "Inherit from parent or project defaults" is un-ticked.
I've found this common when upgrade from old atl projects that the stdafx.cpp has "Inherit from parent or project defaults" un-ticked for some reason.
You should check both the project settings as well as the individual stdafx.cpp file settings to determine that in the Preprocessor Definitions the "Inherit from parent or project defaults" check box is checked. In some cases the Preprocessor Definitions dialog of the Project file is checked however the Preprocessor Definitions dialog of the specific stdafx.cpp file is NOT checked.
Changing the order of Include Directories and included SDK folder works for me:
$(IncludePath);C:\Program Files x86\Microsoft SDKs\Windows\v7.1A\Include
If I put folder C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Include before $(IncludePath), I will get this error.
I also met this issue on VS 2012.
This is caused because you are using the Windows SDK 7.1 which lacks of SetDefaultDllDirectories function call in VS 2012 (VC11). You may notice there is #ifndef _USING_V110_SDK71_ guarded flag to avoid using undefined SetDefaultDllDirectories.
Just define _USING_V110_SDK71_ in your project to let SDK knows you are in this toolset or upgrade to higher version of SDK.
I have had similar problem using VS2008, it was not recognizing a function. I solved it by adding DDX_Control to the DoDataExchange(CDataExchange* pDX).
Put following lines in include above all
$(VC_IncludePath)
$(WindowsSDK_IncludePath)
Uncheck check box "inherit from parent or project defaults"
I copy _USING_V110_SDK71_ in part C/C++ in sub branch preprocessor / preprocessor definition and once unchech inherit from parent ... and do build project and then recheck this option and solved problem
I had the same issue . this trick work for me. this issue comes when visual studio can't load development environment properly . can't load environment variables. so I have tried this and it works fine.
Step #1
Start command prompt of visual studio which you are using
Step #2
run this command .
devenv /useenv
this command will open visual studio and then open your project and compile.
Related
I am using Microsoft Visual Studio Community 2019 Version 16.8.4 on a Windows 10 machine.
I have established that my include files live in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" because I can actually see them listed there. However, I get an error with the line #include <cstdio>.
I have tried right click on project name to bring up a context from which I chose 'Properties'. From the "Solution Project1 Property Pages", I selected "Debug Source Files" and then entered the full directory path to the include files.
I still get the error
You need to add the directory where the headers are found to the project properties under either C/C++ -> Additional include directories or VC++ -> Include directories.
And note that you need to make sure that the directory is added for all project configurations/platforms you wish to be able to build. The Debug source files item is only so that files can be found when running the debugger and have nothing to do with the project build stage.
I ran Visual Studio Installer and noted that one of the workloads, 'Desktop development with C++' had not been activated. After activating it and downloading the required or missing binaries, I am now able to create an empty project using an example of the quintessential 'Hello World' program such as #include int main(){printf("Hello, world");return 0;}
#include <cstdio> is part of the C++ Standard Library headers, if you are getting the error E1696: 'cannot open source file, you might have to retarget the solution/project. Do the following:
Right-click the Solution in the Solution Explorer pane;
Retarget solution;
Follow the steps/press OK.
It worked for me when I couldn't find Standard Library headers, hopefully, it works for you as well.
I am running Visual Studio Community 2017 and Windows 10. I have a project for which I have added an include-file directory under Project > Configuration Properties > VC++ Directories > Include Directories, but Visual Studio simply ignores the directory and will not find the include files. It finds the files if I hard-code the directory into the #include statement. I checked the .vcxproj file and the directory shows up there. I just updated/corrected Visual Studio to the most recent version and have since re-booted, but the problem remains. Help, please!
First, ensure that MFC is enabled in project properties > Configuration Properties > General
use of mfc must be set to static or dynamic library.
then to ensure that cl.exe is using all of the include directories that you specify, you need to go to project properties > c/c++ > general and change suppress startup banner to no /nologo.this will give you the full cl command for each source file, showing exactly what visual studio is attempting to do with the code and configuration options that you give to it.
Additional ideas for troubleshooting this kind of issue:
When using vs2015 you can try to add '#include <somenoneexistingfile.h>' to the top of any .c/.cpp and right-click on it to open a context menu and select "Open Document <somenoneexistingfile.h>. This will open a dialog showing you the actual paths being used for including. Note: This specific approach doesn't work with vs2019 or later.
Besides this, you can check if:
you edited the actual configuration (Debug/Release) which you are starting, i.e. maybe you only edited the additional-include-path for the debug-build but are trying to compile a release-build.
you edited the actual platform (x64 vs x86) which you are starting, i.e. maybe you only configured the additional-include-path for x86 but are trying to compile the x64 platform.
This may be a very simple question but I haven't been able to figure it out so any help is appreciated.
I have a header that is located in a general folder because I want to use it in several projects for example:
C:\user\geninclude\program\header.h
I created a new empty project with a very simple main, in the main I put
#include <program/header.h>
I then went to the project properties and in VC++ in include directories added C:\user\geninclude\
but when I tried to build the program the program tells me it cannot find header.h because is not in the current directory or in the build system path.
I also tried in the project properties in C/C++ general Additional Include Directories adding C:\user\geninclude\ but still the same error.
I know is something simple I am missing, but I don't know what, I am very new to this just learning.
For reference I am using Visual Studio 2013.
Thank you in advance for your help.
UPDATE: Thank you all for your kind responses, I have tried everything you have told me (check release vs debug in both instances, change / for \ and <> for "", and double checking the header and still the system does not see it. It really is very weird. I'll keep trying...
Please check if your file is really an header file otherwise it won't appear on include.
What you can also do (as a workaround if you need that method fast) is to put your header file (or folder with header files) on the visual studio "include" folder. The path should look like this "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
PS: You should also check the properties configuration when you're adding the path to VC++ include directories. You could be adding the path to debug configuration and trying to run it in release mode.
You do indeed want
Project Properties -> Configuration Properties -> C/C++ -> Additional Include Directories
(or something close to that; I'm using VS 2008). Make sure the configuration you're editing in the top left (debug/release) matches the configuration you're building with (typically visible up top in the main window). So it sounds like you may have done it correctly; I'd double-check for the file's existence in that location. You could also try program\header.h instead of program/header.h. If none of those work, try adding C:\user\geninclude\program to the include directories (no \ at the end) and change it to #include "header.h". If that doesn't work either, you've almost surely got the header file in the wrong spot.
Another thing that can cause include files not being picked up is a difference between the platform set in your c++ project's Property Pages and your "Active Solution Platform" in configuration manager. Can just check if one is set to x64 and the other x86
check if you have specified the path correctly. for example I had written cpp instead of c++ and therefore suffered a lot and wasted like an hour searching here and there.
For Visual Studio 2019 users:
Project(P) > yours_project_name properties(P) > Platform Toolset Visual Studio 2019(V###)
Reasoning: You might download the project from Online and they used other version of Visual Studio as Platform.
Project(P) > yours_project_name properties(P) > Windows SDK Version ##.#(latest installed version).
Reasoning: You might download the project from Online and they used version SDK 8.0 while you have SDK 10.0
ntucvhw
While migrating an old C++ project from Visual Studio 6 up to Visual Studio 2012, we came across an odd set of warnings from inside the standard Microsoft platform headers:
warning C4005: '__useHeader' : macro redefinition
warning C4005: '__on_failure' : macro redefinition
An online search only found a few other people running into this error. In some cases, it was people trying to use VS2012 to compile legacy DirectX code - which I am not doing. In other cases, it was people trying to use VS2012 to target Windows XP (using the new option from Update 1) - which I am doing.
The DirectX question was answered that the warning will always be there to tell you that you're compiling with an out-of-date (pre-Win8) version of DirectX, and you'll just have to live with it.
The Windows XP question was not answered. Other people simply said that they couldn't reproduce the problem.
I reproduced it, and found the cause, which I am writing up here to help anybody else who encounters this.
Go into the project properties, and find the "Preprocessor Definitions" field.
In addition to the default and added definition constants, you should see a macro:
%(PreprocessorDefinitions)
This macro apparently brings in some additional compiler-provided preprocessor definitions. I am not sure what version of Visual Studio introduced this macro, but it was not there in Visual Studio 6.
In Visual Studio 2012, this macro is required to be present in your project's Preprocessor Definitions field. It may also be required in earlier versions of Visual Studio, but I have not tested these.
If this macro is missing, you will see the error messages as shown above.
UPDATE:
See Edmund's answer to this same question first -- give that a try. If it works, great! If not... try the following:
ORIGINAL:
Use the workaround mentioned on the "Workarounds" tab of this web page:
http://connect.microsoft.com/VisualStudio/feedback/details/789965/resource-editor-warning-rc4005-on-toolset-visual-studio-2012-windows-xp-v110-xp
Namely, add:
#define _USING_V110_SDK71_ 1
...directly in the .rc file before it includes anything that would include the system headers that cause this warning.
Haven't found a solution to this published anywhere online, so here's what worked for me.
I'm building a project with 110_xp tools
I get these warnings ...
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\sal_supp.h(57): warning C4005: '__useHeader' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2872) : see previous definition of '__useHeader'
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\specstrings_supp.h(77): warning C4005: '__on_failure' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2882) : see previous definition of '__on_failure'
Clearly an inconsistency between the VC 11 headers and 7.1a sdk headers.
In my stdafx.cpp I did this ...
#define _USING_V110_SDK71_
#include "stdafx.h"
... the build problem has gone away.
This is a resource compiler warning. The solution is easy. Right click on the .rc file in the solution explorer and choose Properties. Now go to Resources > General > Preprocessor Definitions, and add
%(PreprocessorDefinitions)
Adding #define _USING_V110_SDK71_ in Stdafx.cpp or Stdafx.h would not work if your cpp files do not have precompiled headers.
To solve this problem, the following works.
Right-click project in Solution Explorer* → Properties → C/C++ → Preprocessor → Preprocessor definition → edit → Add _USING_V110_SDK71_
For me another solution worked.
In project Properties → Configuration properties → C/C++ → General, I changed the field Addition Include Directories path to SDK with this macro:
$(WindowsSDK_IncludePath)
Before that, this field had the path to my SDK v7.1, and I had the same warnings.
It is still simpler.
Just check the checkbox "Inherit from parent or project defaults" in Configuration Properties → C/C++ → Preprocessor / Preprocessor Definitions → Edit.
I had this problem in some projects that originated with VC++ 2003 and have been incrementally upgraded over the years. I found that while the project settings had %(PreprocessorDefinitions) in Preprocessor Definitions, a few of the .cpp files didn't (The oldest ones). After changing them to "Inherit from parent or project defaults" it got rid of the warnings.
For me this happened with Visual Studio 2017 (both fresh and repaired installation). Obviously the Windows 7.1 SDK had been installed before VS2017 and had been integrated into a Visual Studio 2005 installation.
In my case the two files:
%LOCALAPPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props
%LOCALAPPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props
contained references to the include directories and libraries of the Windows 7.1 SDK. Removing these references did the job.
Keep in mind that every single C++ project for Win32 and x64 respectively inherits from these property sheets.
Although this answer is for VS10, it's of interest as might provide some clues as to what's going on viz the VC++ directories macros:
The warning appeared when these statements were added in the header file of a project, MyApp:
#ifndef NTDDI_WINXPSP3
#define NTDDI_WINXPSP3 0x05010300
#endif
#ifndef NTDDI_VISTA
#define NTDDI_VISTA 0x06000000
#endif
#ifndef NTDDI_VISTASP1
#define NTDDI_VISTASP1 0x06000100
#endif
#ifndef NTDDI_WS08
#define NTDDI_WS08 0x06000100
#endif
Warnings like the following popped up for all but the XPSP3 def.:
Warning RC4005: 'NTDDI_VISTASP1' : redefinition C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\sdkddkver.h.., MyApp
MyApp was a WinDebug 32 build, noting Windows7.1SDK appeared in the X64 section of the proj file:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PlatformToolset>Windows7.1SDK</PlatformToolset>
The inherited value for Preprocessor Definitions was _VC80_UPGRADE=0x0600. Having used the SDK toolset prior to reverting to V100, the SDK libraries were found as inherited_from in Include directories and Library Directories in the VC++ Directories section, as noted here.
Looks like the warning is generated as a result of a combination of upgrading, migration, or toolset changes.
Edit: An unrelated issue in VS2017 (MBCS) is opting to use
LoadCursorW(nullptr, IDC_ARROW)
instead of the default LoadCursorA(...) in a WNDCLASSEXW structure. A possible solution is to redefine like so:
#define IDC_ARROW MAKEINTRESOURCEW(32512)
Here the warning can be suppressed by using the #undef procedure prior to the #define:
#ifdef IDC_ARROW
#undef IDC_ARROW
#endif
#define IDC_ARROW MAKEINTRESOURCEW(32512)
I know this is old question, but... "sometimes they come back" :)
Faced same warnings after install VS 2012 Express at fresh OS. After some investigation i decided to compare my current Program Files (x86)\Microsoft Visual Studio 11.0\VC\include folder with the same folder with VS 2012 Update 4.
Here is comparison result:
And sal.h diffs:
So simple copying __useHeader's checks fixed all warnings.
I'm a novice C++ developer. I encontered the error message indicates "LINK :fatal error LNK1104: cannot open file 'MSVCRTD.lib'" while I'm trying to debug every single project in Microsoft Visual C++ 2010 Express. I searched on Stack overflow and Google for any possible resolution, but I couldn't find exact and precise answer. What I have understood is that the "msvcrtd.lib" file should be in "\Microsoft Visual Studio 10.0\VC\lib", but that file is not there in my case. What should I do?
For the poor souls out there who are struggling with this, after an hour of research I found a solution for my Visual Studio Enterprise 2017:
First, lets find where is your library file located:
With windows explorer, go to your directory where Visual Studio is installed, (default: C:\Program Files (x86)\Microsoft Visual Studio) and do a search for msvcrtd.lib
I found mine to be in here:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86
Quick Fix (for one project only):
Right click on your project, click on properties, navigate to Linker, add that path to Additional Library Directories
Permanent Fix (for all projects)
Open a project
navigate to View > Property Manager (it could be under Other Windows)
Expand all folders and multi select all "Microsoft.cpp.Win32.user" & "Microsoft.cpp.64.user"
Right click and go to properties
Navigate to VC++ Directories
Add the path to default Library Directories
Go to your project properties, select Linker from left. Add this to "Additional Library Directories":
"(Your Visual Studio Path)\VC\lib"
For example:
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib
I came across this problem when compiling a sample app using VS2017
Hope this will help
There is a check box that says "Inherit from parent or project defaults" in some of the property dialogs in Project Properties. Make sure that check box is checked for your Include and Library directories property windows and of course for your Additional Dependencies window.
If you use VS2017, please read it. Or just ignore this answer...It may be invalid for other VS version.
Do not trust anyone who told you to add lib path.
Here's suggestions:
[BEST] You just need to install these via VS_installer (most of us just need x86/x64 version below)
VC++ 2017 version version_numbers Libs for Spectre [(x86 and x64) | (ARM) | (ARM64)]
Visual C++ ATL for [(x86/x64) | ARM | ARM64] with Spectre Mitigations
Visual C++ MFC for [x86/x64 | ARM | ARM64] with Spectre Mitigations
[NAIVE] or disable Spectre Option for every Solution
(Why We are so hard to global disable it)
[LAUGH] Or never use VS2017
This is VisualStudioTeam's fault and Microsoft is guilty.
Why?
You can't make a global configuration to disable /QSpectre, and IDK when and why VS2017 enable it in one day. So the best way is install Spectre? ahhha?
For VS 2019, Spectre Mitigation is enabled by default.
So the right way to fix the issue would be to install VC++ Libs for Spectre.
But, to quickly resolve the issue, you may disable Spectre Mitigation
Project Properties -> C/C++ -> Code Generation -> Spectre Mitigation -> Disabled
https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
I ran into this issue. The file existed on my machine, it was in the search path. I was stumped as the error result is really unhelpful. In my case I had turned on Spectre mitigation, but had not downloaded the runtime libs for Spectre. Once I did the download all was right with the world. I had to get this installed on my CI build servers also, as these libs are not installed with VS by default.
I have solved this problem, you need install all spectre lib.
Vistual Studio Installer->Modify->Component->Any spectre lib.
This solution can be adapted to any project.
For me this issue happens after installing the (Windows Driver Kit): https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
Uninstalling it fixes the problem. Just posting here as a related issue for people looking for solutions: After installing WDK VC++ is broken
Scenario:
Windows 10 with Visual Studio 2017 (FRESH installation).
'C' project (LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib').
Resolve:
Run 'Visual Studio Installer'.
Click button 'Modify'.
Select 'Desktop development with C++'.
From "Installation details"(usually on the right-sidebar) select:
4.1. VC++ 2015.3 v14.00(v140) toolset for desktop.
Version of 'toolset' in 4.1. is just for example.
Click button 'Modify', to apply changes.
Right-click 'SomeProject' -> 'Properties' ->
'Linker' ->
'General' ->
'Additional Library Directories': $(VCToolsInstallDir)\lib\x86
(!!! for x64 project: 'Additional Library Directories': $(VCToolsInstallDir)\lib\x64 !!!)
it is also worth checking that MSVCRTD.lib file is present in "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib" for x64 and in C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib for 32 bit. Sometimes VS might not be installed properly OR these files might get deleted accidentally.
I just had this error, in my case rebuilding the project while doing nothing else worked for me.
Here's my situation
Visual studio crashed and I had to re-install and my new installation path is different than the previous one. then I had this error
the error showed that the library is located at
D:\program\Microsoft Visual Studio\...
while it should be
D:\program files\Microsoft Visual Studio\...
as I said I just rebuilt it and it worked for me and if you have a multi-solution project you have to rebuild the whole-solution
I solved the problem by adding #using <mscorlib.dll> in the main file
This indicates that Visual Studio wasn't able to find the lib (Library) directory which contains msvcrtd.lib.
IMPORTANT: This lib directory also contains linkers required during the compilation process.
So, all you need to do is override the Library Directory location. You can do so with the help of Environment Variables.
I referred to this StackOverflow Post for help. As per the answer posted, the Environment Variable LIB refers to the path where the Linker Libraries are located. Why is this method better? Because this will apply to all the projects instead of just a particular project. Also, you don't need to download anything extra. It just works...
Follow the steps below to achieve this:
STEP-1: Search for "msvcrtd.lib" in the search bar.
STEP-2: Click "Open File Location" (available in context menu)
STEP-3: Copy the address of the directory from the address bar.
STEP-4: Search "Environment" in the taskbar and click on "Edit the system environment variables".
STEP-5: Click on "Environment Variables..." button.
STEP-6: Under "System variables" section, click on "New..." button. A dialog would pop up.
STEP-7: In the dialog box, enter the following:
Variable name: LIB
Variable value: [The directory you copied in "STEP-3"]
And press "OK"
Now, you are all done!
The above answer was not quite accurate for me. I have VS2010 Ultimate installed and the file in question is not in my Visual Studio 10.0\VC folder. Rather I found it in the Visual Studio 9.0\VC folder. So if that's the case for anyone, follow the lead to change the Linker but use the Visual Studio 9.0\VC folder instead. It worked for me.
For Visual Studio 2017
Go to your project properties, select Linker from left. Add this to "Additional Library Directories":
C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\lib
I got a slightly different error
LNK1104 cannot open file 'MSVCURTD.lib'
Note it is msvcUrtd (not msvcrtd), but the file is not found on my system.
Solved it by setting the following options:
Project Properties
General
Character Set: Not Set
Common Language Runtime Support: Common Language Runtime Support (/clr)
Hope that helps.
In VS2017 (Community/Enterprise/Ultimate/Professional):
Add the path(s) of the folder(s) which include your desired ".lib" file(s) in the following path in VS:
(Right Click)Project(in Solution Explorer)->Properties->Configuration Properties->Linker->General->Additional Library Directories
If there are more than one ".lib" file use ';' to separate them otherwise click on the edit box corresponds to "Additional Library Directories" then click on "" in drop down menu and add all desired ".lib" files in newly opened window one by one and in a easy to handle manner.
I ran into this using Visual Studio 2017. I tried the solutions suggested here with explicitly adding paths to where the 'MSVCRT.lib' file was located. But I felt this probably wasn't the correct approach because previously for the past several weeks this had not been a problem with my project.
After trial and error, I discovered that if I left an empty or blank value in the Linker --> Input section, it would give me the error about LNK1104: cannot open file 'MSVCRT.lib'. Eventually I figured out that I should leave this value there instead.
On the Visual Studio project, right-Clicking on the project item in the Solution explorer panel (not the Solution itself, which is the topmost item), then select Properties. From there do the following:
Linker --> Input : %(AdditionalDependencies)
This additional information might be helpful, if you got into the situation the same way I did. I have discovered that I should not put any non-system library paths in the Linker --> Input section. With my project I was trying to compile with external .lib files. Previously I had a value in this input section like: $(ProjectDir)lib; %(AdditionalDependencies) but this lead to other problems. I discovered the correct place (it seems so far) to put paths for referencing external .lib files in a C/C++ project in Visual Studio 2017 is here:
VC++ Directories --> Library Directories : $(ProjectDir)lib; $(LibraryPath)
Note the $(LibraryPath) value will include extra values such as inherited from parents. My folder project contained a folder called 'lib' which is why I had the first value there before the semicolon.
I have included the following path
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x86
and
C:\local\boost_1_64_0\lib64-msvc-14.1
To
project properties-> linker-> Additional Directories
Click here : Image shows linking of boost and MSVC2017