使用Cmake编译DLL

时间:2014-08-07 14:21:32

标签: c++ windows dll cmake

我目前正在尝试使用cmake和MinGW(x64)在Windows上编译dll,但我想 静态链接c ++运行时到我的dll,以便在不添加c ++的情况下部署我的dll。

我的CMakeLists.txt看起来像这样:

cmake_minimum_required(VERSION 2.8)

set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -static-libgcc ")

project(Comp)

set (BUILD_SHARED_LIBS OFF)

include (GenerateExportHeader)

FIND_PACKAGE(ITK)

IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
  MESSAGE(FATAL_ERROR <<ITK not found.>>)
ENDIF(ITK_FOUND)

INCLUDE_DIRECTORIES(${ITK_LIBRARY_DIRS})
LINK_DIRECTORIES(${ITK_LIBRARY_DIRS})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories($ENV{JAVA_HOME}/include)
include_directories($ENV{JAVA_HOME}/include/win32)

add_library(mylib SHARED source/mysources.cxx)

target_link_libraries(mylib ${ITK_LIBRARIES})

但是当我检查生成的dll文件时,我的MinGw文件夹中仍然依赖于dll。 如何配置CMakeLists.txt去除依赖项espacialy libstc ++ - 6.dll和libgcc_s_seh-1.dll?

祝你好运

0 个答案:

没有答案