# installation of vtk 9.0 with python, java wrappers

hi all,

I tried to install java and python wrappers in order to use them for calling VTK APIs, over last three days I have tried different approaches. first VTK_BUILD?SHARED checked in CMake apparently that failed in installation stage because of missing .pyd library file for python, I guess it was vtkIOVeraOut.cp36-win.amd64.pyd if I am not wrong. I search the download vtk source files and could not find it. then I tried to install it in release mode and that also failed, today I tried to uncheck VTK_BUILD_SHARED so everything builds and I still have problems building, I saw a project failed to build at project number 490, and some other problems raised with my pc after 10 hours of continues build of vtk 9.0.

Q. has anybody managed to include java and python wrappers checked in CMake and succeeded to install VTK 9.0,

help is needed , I appreciate in advance!!

Regards,
sohrab

Could you post the actual errors you get from the compiler and/or build?

Hi Ben,

CMake Configuration:

1. wrapping for java and python is checked!

2. BUILD_SHARED_LIBS UNCHECKED!.

3. config + generate -> vtk.sln is in bin folder of vtk build from code!

VS2017 BUILD: X64, DEBUG, ALL_BUILD->BUILD

FOLLOWING IS THE OUTPUT SCREEN OF COMPILE + LINK IN VS2017

errors.txt (1.27 MB)

@ben,
CMake is used to generate a vtk.sln solution for vs2017
EDI: (VS2017 + x64/debug) build
I just responded to your email from my gmail. I hope that helps, As I explained the errors are for a static build BUILD_SHARED_LIBS IS UNCHECKED! I also have missing libraries which I hope it is because of compilation errors which consequently resulted in missing libraries.

Missing libraries:
…/…/lib/debug/vtkCommonExecutionModelJava.lib
…/…/lib/debug/vtkCommonCoreJava.lib
what do you think the compilation errors resulted in not building these libraries so they are missing!?

Regards,
Sohrab Azami

I don’t know how well Java support with static libraries is supported. It looks like “not 100%”. I suggest doing a shared build if you need Java right now. If you chase the errors back to the source, you find this output:

92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(45): error C2375: 'vtkJavaGetPointerFromObject': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(28): note: see declaration of 'vtkJavaGetPointerFromObject'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(50): error C2375: 'vtkJavaMakeJArrayOfDoubleFromDouble': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(37): note: see declaration of 'vtkJavaMakeJArrayOfDoubleFromDouble'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(75): error C2375: 'vtkJavaMakeJArrayOfDoubleFromFloat': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(35): note: see declaration of 'vtkJavaMakeJArrayOfDoubleFromFloat'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(100): error C2375: 'vtkJavaMakeJArrayOfIntFromInt': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(41): note: see declaration of 'vtkJavaMakeJArrayOfIntFromInt'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(125): error C2375: 'vtkJavaMakeJArrayOfIntFromIdType': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(42): note: see declaration of 'vtkJavaMakeJArrayOfIntFromIdType'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(150): error C2375: 'vtkJavaMakeJArrayOfIntFromLongLong': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(44): note: see declaration of 'vtkJavaMakeJArrayOfIntFromLongLong'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(175): error C2375: 'vtkJavaMakeJArrayOfIntFromSignedChar': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(46): note: see declaration of 'vtkJavaMakeJArrayOfIntFromSignedChar'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(200): error C2375: 'vtkJavaMakeJArrayOfFloatFromFloat': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(33): note: see declaration of 'vtkJavaMakeJArrayOfFloatFromFloat'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(225): error C2375: 'vtkJavaMakeJArrayOfShortFromShort': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(39): note: see declaration of 'vtkJavaMakeJArrayOfShortFromShort'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(250): error C2375: 'vtkJavaMakeJArrayOfByteFromUnsignedChar': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(50): note: see declaration of 'vtkJavaMakeJArrayOfByteFromUnsignedChar'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(276): error C2375: 'vtkJavaMakeJArrayOfLongFromLong': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(48): note: see declaration of 'vtkJavaMakeJArrayOfLongFromLong'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(302): error C2375: 'vtkJavaMakeJArrayOfUnsignedLongFromUnsignedLong': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(62): note: see declaration of 'vtkJavaMakeJArrayOfUnsignedLongFromUnsignedLong'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(329): error C2375: 'vtkJavaMakeJArrayOfUnsignedShortFromUnsignedShort': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(60): note: see declaration of 'vtkJavaMakeJArrayOfUnsignedShortFromUnsignedShort'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(356): error C2375: 'vtkJavaMakeJArrayOfUnsignedCharFromUnsignedChar': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(56): note: see declaration of 'vtkJavaMakeJArrayOfUnsignedCharFromUnsignedChar'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(383): error C2375: 'vtkJavaMakeJArrayOfUnsignedIntFromUnsignedInt': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(58): note: see declaration of 'vtkJavaMakeJArrayOfUnsignedIntFromUnsignedInt'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(410): error C2375: 'vtkJavaMakeJArrayOfCharFromChar': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(54): note: see declaration of 'vtkJavaMakeJArrayOfCharFromChar'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(517): error C2375: 'vtkJavaUTFToChar': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(29): note: see declaration of 'vtkJavaUTFToChar'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(522): error C2375: 'vtkJavaUTFToString': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(30): note: see declaration of 'vtkJavaUTFToString'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(535): error C2375: 'vtkJavaMakeJavaString': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(31): note: see declaration of 'vtkJavaMakeJavaString'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(565): error C2375: 'vtkJavaVoidFunc': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(74): note: see declaration of 'vtkJavaVoidFunc'
92>C:\vtk\src\Utilities\Java\vtkJavaUtil.cxx(582): error C2375: 'vtkJavaVoidFuncArgDelete': redefinition; different linkage
92>c:\vtk\src\utilities\java\vtkJavaUtil.h(75): note: see declaration of 'vtkJavaVoidFuncArgDelete'


Cc: @dgobbi

Hi Sohrab,

VTK can often be tricky to build, especially with Python and Java wrappers, but it can definitely be done. It’s even done as part of the automated nightly testing.

However, there are some considerations:

1. If you want to build the wrappers, set BUILD_SHARED_LIBS to ON. Otherwise, the wrappers will not work as you expect. Trying to build the wrappers with static libraries is just a waste of time unless you really need static libraries.

2. For VTK 9.0, building the Java wrappers inside Visual Studio will not work. Right now, the only way to build Java wrapping on Windows is from the “VS Developer Command Prompt” with the Ninja generator. This will probably be fixed for VTK 9.1.

VTK 9.0 also has issues with embedding the VTK render window within a Java GUI, this should also be fixed in 9.1.

In summary, I think your best option right now is to only use Python wrapping (and definitely check BUILD_SHARED_LIBS). For Java, wait for VTK 9.1.

@ben.boeckel I can check the attributes and specifiers for the generated Java methods. But it’s probably worth repeating that I’m really no expert on the Java wrapping, and I’m not even a Java programmer.

We might be able to get the Java fixes into 9.0.1: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/6902

These are attributes on the vtkJavaUtil functions. I don’t think there’s any generated code in that error message.

Hi ben
Firstly Thank you sir about your help, secondly I don’t know how to run build from vs developers command prompt with ninja generator!? I will do CMake with BUILD_SHARED_LIBS! afterwards what is the command line for build from command prompt with ninja generator!?

Regards,

Sohrab Azami

Hi Sohrab,

The “x64 Native Tools Command Prompt” is in the Windows Start menu (under the Visual Studio 2017 menu).

Once you are in the command prompt, all the build commands should be run from this prompt. First, you should “cd” to your build folder, and then you can run cmake, and then ninja:

cd \path\to\vtk-build
cmake ..\vtk-source -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DVTK_WRAP_JAVA=ON -D VTK_WRAP_PYTHON=ON
ninja


The visual studio command prompt comes with “cmake” and “ninja” as built-in commands, so you don’t even have to download ninja yourself.

@dgobbi

Firstly thank you for your response. secondly I followed the instruction you wrote in your message:
cmake …\src -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DVTK_WRAP_JAVA=ON -DVTK_WRAP_PYTHON=ON ninja

but I received error message: CMake Error: The source directory c:\vtk\bin\ninja does not exist specify --help for usage, or press the help button on the CMake GUI.

Please inform me what do you make of this error message and how could I do ninja generation of my source code and built VTK tool