Saturday, April 10, 2021

error : Please use the /MD switch for _AFXDLL builds

#error Please use the /MD switch for _AFXDLL builds

  1. #error Please use the /MD switch for _AFXDLL builds
  2. This is a paragraph.I encountered an error in Visual Studio, Please use the /MD switch for _AFXDLL builds so if I undefine the _AFXDLL, will my program go wrong?

    A Solution: Settings for CRT linking and MFC linking must be coherent. So, actually, there are two possible answers at this question:

    1. Use /MT (Properties -> C/C++ -> Code Generation) and static MFC (Properties -> General -> Use of MFC)
    2. Use /MD (Properties -> C/C++ -> Code Generation) and shared MFC (Properties -> General -> Use of MFC)

    Yes it will. What you should do is is go to your Visual Studio project properties:

    In Configuration Properties -> C/C++ -> Code Generation make sure you are using the Multi-threaded Dll for your Runtime Library.

    That will solve your problems.

  3. error Please use the /MD switch for _AFXDLL builds
  4. I have following error

    C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxver_.h(77): catastrophic error: #error directive: Please use the /MD switch for _AFXDLL builds
    I have set
    Use MFC in a Static Library
    and
    Multi-threaded Debug (/MTd) in runtime library.

    A Solution: I don't think that code block should be used, it will do more harm than good

    I agree, the build system for Visual C++ application is horrendous, the error messages are indecipherable and I have probably spent more time debugging this side of things than anything else, however, this I believe is the problem and the solution.

    In your project properties, Go to

    Configuration Properties => General Have a look at Use of MFC If this is set to Use MFC in a shared DLL Then go to C++ ==> Code Generation And look at Runtime Library This should be set to Multi Threaded Dll

    Basically what happens is, the first option (Use MFC in a shared DLL) sets the preprocessor directive _AFXDLL the second option (Multi Threaded DLL) sets the compiler directive /Md

    Clear as mud eh?

    I've encountered the same error in a number of different Win32 DLL projects, all of which had /MD switch applied.

    IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds

    I reported the problem in July 2011 and Microsoft confirmed there was a bug, but promised to fix it in the next major release.

    http://connect.microsoft.com/VisualStudio/feedback/details/650507/intellisense-error-directive-please-use-the-md-switch-for-afxdll-builds

    A Solution: Since submitting this bug report, I've come to realise that it's nothing to do with MFC static libraries. There's just something wrongwith Intellisense. Seemingly, there isn't an easy fix. Trying the following sometimes makes this the erroneous 'error' go away:

    1. C++ Code Generation set to /MT, press Apply and then set it back to /MD (see above)
    2. Close and reopen the Solution
    3. Close and restart Visual Studio
    4. Remove the Project from the Solution and add it back as existing project
    At present, having tried all of the above I'm still stuck with this error message ;-)

    Side Note: Thanks for your advice! That helped and additionally I removed solution's suo file before restarting VS2010.

    A Side Note: Also - check that you are consistent with Release and Debug builds. The configuration properties may be different.

    +1 for "Intellisense problem" My (personal) solution: Restart VS 2010 with admin rights...

  5. Error C1189: #error: Please use the /MD switch for _AFXDLL builds(转)
  6. a collection of ideas works.

No comments:

Post a Comment