目前它正在动态链接它,给我带来了很多麻烦(缺少msvcr80.dll )。
我应该如何指示cmake静态链接它?
答案 0 :(得分:1)
这就是我为我的项目所做的事情:
set (BUILD_SHARED_LIBS FALSE) # should force the libraries to be static if (WIN32) if (${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008") # for some reasons VS 9 generator doesn't overwrite the flags # but generator VS 2010 does if (BUILD_SHARED_LIBS) set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MDd") set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MDd") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MD") set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MD") else() set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MTd") set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MTd") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MT") set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MT") endif() endif() # other windows specific flags endif()
答案 1 :(得分:0)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")