ITK: 在执行 HelloWorld Example 时找不到 ITKCommon-x.xx.dll

ITK: Can't find ITKCommon-x.xx.dll when executing HelloWorld Example

我使用最新的 Visual Studio 版本(Visual Studio 15 2017 Win64 编译器)在 Windows 10 上成功构建了 ITK 4.13(如 'Release')。然后我尝试使用以下 CMakeLists.txt 构建 ITKHelloWorld 示例(如 ITK 示例所示):

#CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(HelloWorld)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(HelloWorld HelloWorld.cxx)
target_link_libraries(HelloWorld ${ITK_LIBRARIES})

内置运行没有错误或警告。 运行 生成的 HelloWorld.exe 文件导致 ITKCommon-4.13.dll not found 错误。

ITKCommon-4.13.dll 是由 ITK 构建的,因此,我想我必须更改 CMakeList 文件中的某些内容,但不知道是什么。

有什么猜测或解决办法吗?

编辑:CMakeLists中的include(${ITK_USE_FILE})表达式搜索UseITK.cmake,但是这个文件位于ITK的源中,不在构建文件夹。这可能是错误的来源吗?

Edit2: 运行 一个 VTK 示例还显示了由于未找到所需的 .dlls.

而导致的错误

你的项目没有问题。 Windows 仅当它们位于 PATH 位置时才能在运行时使用 dll 库。所以有两种选择:要么将 ITK 库的 bin/Release 目录添加到 Windows 的 PATH 系统变量(包含所有 ddls 的目录),要么将所有 dll 从该目录复制到包含您的新应用程序的那个。

准确地说,你不需要复制所有的dll,你可以通过例如检查Dependency Walker,哪些是真正需要的。