VTK:使用 Java 包装器编译 - vtk.jar 缺失

VTK: Compiling with Java Wrappers - vtk.jar missing

我正在尝试使用 Visual Studio 2019 在 Windows 10 下构建 VTK,以便在 Java 中使用,基本上是根据这个 this and this 教程。 cmake 部分似乎工作正常。我最终得到以下配置:

Visual Studio 中的构建步骤(构建 ALL_BUILD)和 Release 解决方案配置 x64 作为管理员似乎也有效:

========== Build: 437 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

然而,执行 INSTALL 以错误结束:

225>CMake Error at Wrapping/Java/cmake_install.cmake:1215 (file):
225>  file INSTALL cannot find
225>  "[PATH]/VTK-9.0.1/Binaries/lib/java/Release/vtk.jar":
225>  File exists.
225>Call Stack (most recent call first):
225>  cmake_install.cmake:486 (include)
225>
225>
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: The command "setlocal
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: D:\Programme\CMake.20.3\bin\cmake.exe -DBUILD_TYPE=Release -P cmake_install.cmake
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmEnd
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmErrorLevel
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: exit /b %1
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmDone
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
225>D:\Programme\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :VCEnd" exited with code 1.
225>Done building project "INSTALL.vcxproj" -- FAILED.

确实,[PATH]/VTK-9.0.1/Binaries/lib/java/Release/ 中有很多 *.exp*.lib 文件,但缺少 vtk.jar

知道我做错了什么吗?

好的,最好多搜索 3 分钟。但为了完整起见,这里是解决方案:

https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/19

精华:

The VS cmake does not know how to build java files so the last stage of building the jar file has to be done manually since vtk 9.0.0

相关代码来自link

cd $vtk_build_dir\Wrapping\Java
dir /s/B *.java >javafiles
javac -d ..\..\java @javafiles
cd ..\..\java
jar --create -f  ..\lib\java\vtk.jar vtk\*.class