首页 > 解决方案 > VTK:使用 Java Wrappers 编译 - 缺少 vtk.jar

问题描述

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

在此处输入图像描述

ALL_BUILDVisual Studio 中的构建步骤 (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 Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: The command "setlocal
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: D:\Programme\CMake\3.20.3\bin\cmake.exe -DBUILD_TYPE=Release -P cmake_install.cmake
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmEnd
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmErrorLevel
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: exit /b %1
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmDone
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
225>D:\Programme\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :VCEnd" exited with code 1.
225>Done building project "INSTALL.vcxproj" -- FAILED.

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

任何想法我做错了什么?

标签: javavisual-studiocmakevtk

解决方案


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

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

精华:

VS cmake 不知道如何构建 java 文件,因此构建 jar 文件的最后阶段必须从 vtk 9.0.0 开始手动完成

链接中的相关代码

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

推荐阅读