Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top