使用CMake生成MFC项目的时候,需要用到在共享DLL中使用 MFC,需要在CMakeLists文件中加上如下的代码:
ADD_DEFINITIONS(-D_AFXDLL)
SET(CMAKE_MFC_FLAG 2)
ADD_EXECUTABLE(detect WIN32 ${DIR_SRCS})
CMAKE_MFC_FLAG参数的意思是这样解释的:
To use MFC, the CMAKE_MFC_FLAG variable must be set as follows:
0: Use Standard Windows Libraries
1: Use MFC in a Static Library
2: Use MFC in a Shared DLL