开发者

How do I force cmake to link MSVCR.dll statically in windows XP?

Currently it's linking it dynamically,causing much trouble for me(missing msvcr80.dll).

How should I instruct cmake to li开发者_JAVA百科nk it statically?


This is what I do for my projects:

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()


set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜