Unexplainable error “Please use the /MD switch for _AFXDLL builds”

别等时光非礼了梦想. 提交于 2020-01-24 21:13:29

问题


I use VisualStudio2010 and CMake 2.8.12.1. I created a CMakeLists.txt for a MFC project. MFC capability was done by following lines in the CMake file:

add_definitions(-D_AFXDLL) #enables MFC
set(CMAKE_MFC_FLAG 2)      #use shared MFC library

Furthermore the project will be build with MD as runtime library (default). But now I want my project to be build as MT (which also requires to specify static MFC library). So I replaced the lines above with:

add_definitions(-D_AFXDLL)          #enables MFC
set(CMAKE_MFC_FLAG 1)               #use static MFC library
set(CMAKE_CXX_FLAGS_RELEASE "/MT")  #set release configuration to MT
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")   #set debug configuration to MTd

If I build my project now, I get error message:

fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds

As far as I know this means that there's a mismatch between MT/MD on one side and static/shared MFC library on the other side. I checked the configuration in my project settings once again. Runtime library IS set to MT and MFC library IS set to static. So I do not understand the error. Does anybody know help? Did I miss something?

Regards, Michael


回答1:


_AFXDLL is never used with a static MFC build! _AFXDLL.

_AFXDLL is only set when the shared MFC builds are used.

Also static MFC build implies a static CRT.



来源:https://stackoverflow.com/questions/22963397/unexplainable-error-please-use-the-md-switch-for-afxdll-builds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!