error C2039: “SetDefaultDllDirectories”:is not a m

2020-03-11 03:58发布

问题:

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

回答1:

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.



回答2:

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.



回答3:

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.



回答4:

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).



回答5:

  1. Put following lines in include above all

    $(VC_IncludePath)
    $(WindowsSDK_IncludePath)

  2. Uncheck check box "inherit from parent or project defaults"



回答6:

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



回答7:

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.



标签: mfc