[vtkusers] Android Integration crash with VTK 8.1

Callebaut Benoit benoit.callebaut at worldline.com
Thu Feb 1 05:18:36 EST 2018


Hello,
I am trying to integrate VTK 8.1 in a Java application. Base example is the JavaVTK example using gradle.
The only change compared to the original one is that I am using gradle as build system with CMake. The VTK libraries are prebuilt static libraries.

I compiled the libraries separately on my system and put them in the jniLibs directory.
I am able to compile and run the APK on my device (Android 7.0)
But VTK is crashing on the first native call : vtkRenderWindow *renWin = vtkRenderWindow::New();
I was able to track it to a call to vtkAtomic call
Unfortunately I am unable to debug correctly in C++ on my installation.

Hereunder is my CmakeLists for info

Could somebody help me ? I am probably doing something wrong.
Thanks,
Benoit Callebaut
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

set(JNIBASE ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/armeabi-v7a)

add_library( # Sets the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             src/main/cpp/native-lib.cpp )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )
find_library( # Sets the name of the path variable.
              dl

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              dl )
find_library( # Sets the name of the path variable.
              z

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              z )
find_library( # Sets the name of the path variable.
              android

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              android )
find_library( # Sets the name of the path variable.
              EGL

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              EGL )
find_library( # Sets the name of the path variable.
              GLESv2

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              GLESv2 )


# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

add_library( vtkalglib-8.1 STATIC IMPORTED )
set_target_properties(vtkalglib-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkalglib-8.1.a)
add_library( vtkCommonColor-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonColor-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonColor-8.1.a)
add_library( vtkComputationalGeometry-8.1 STATIC IMPORTED )
set_target_properties(vtkComputationalGeometry-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonComputationalGeometry-8.1.a)
add_library( vtkCommonCore-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonCore-8.1.a)
add_library( vtkCommonDataModel-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonDataModel-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonDataModel-8.1.a)
add_library( vtkCommonExecutionModel-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonExecutionModel-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonExecutionModel-8.1.a)
add_library( vtkCommonMath-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonMath-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonMath-8.1.a)
add_library( vtkCommonMisc-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonMisc-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonMisc-8.1.a)
add_library( vtkCommonSystem-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonSystem-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonsystem-8.1.a)
add_library( vtkCommonTransforms-8.1 STATIC IMPORTED )
set_target_properties(vtkCommonTransforms-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkCommonTransforms-8.1.a)
add_library( vtkDICOMParser-8.1 STATIC IMPORTED )
set_target_properties(vtkDICOMParser-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkDICOMParser-8.1.a)
add_library( vtkexpat-8.1 STATIC IMPORTED )
set_target_properties(vtkexpat-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkexpat-8.1.a)
add_library( vtkFiltersCore-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersCore-8.1.a)
add_library( vtkFiltersExtraction-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersExtraction-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersExtraction-8.1.a)
add_library( vtkFiltersGeneral-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersGeneral-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersGeneral-8.1.a)
add_library( vtkFiltersGeometry-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersGeometry-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersGeometry-8.1.a)
add_library( vtkFiltersModeling-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersModeling-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersModeling-8.1.a)
add_library( vtkFiltersSources-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersSources-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersSources-8.1.a)
add_library( vtkFiltersStatistics-8.1 STATIC IMPORTED )
set_target_properties(vtkFiltersStatistics-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkFiltersStatistics-8.1.a)
add_library( vtkfreetype-8.1 STATIC IMPORTED )
set_target_properties(vtkfreetype-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkfreetype-8.1.a)
add_library( vtkImagingCore-8.1 STATIC IMPORTED )
set_target_properties(vtkImagingCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkImagingCore-8.1.a)
add_library( vtkImagingFourier-8.1 STATIC IMPORTED )
set_target_properties(vtkImagingFourier-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkImagingFourier-8.1.a)
add_library( vtkImagingMath-8.1 STATIC IMPORTED )
set_target_properties(vtkImagingMath-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkImagingMath-8.1.a)
add_library( vtkInfovisCore-8.1 STATIC IMPORTED )
set_target_properties(vtkInfovisCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkInfovisCore-8.1.a)
add_library( vtkInteractionStyle-8.1 STATIC IMPORTED )
set_target_properties(vtkInteractionStyle-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkInteractionStyle-8.1.a)
add_library( vtkIOCore-8.1 STATIC IMPORTED )
set_target_properties(vtkIOCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOCore-8.1.a)
add_library( vtkIOGeometry-8.1 STATIC IMPORTED )
set_target_properties(vtkIOGeometry-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOGeometry-8.1.a)
add_library( vtkIOImage-8.1 STATIC IMPORTED )
set_target_properties(vtkIOImage-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOImage-8.1.a)
add_library( vtkIOInfovis-8.1 STATIC IMPORTED )
set_target_properties(vtkIOInfovis-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOInfovis-8.1.a)
add_library( vtkIOLegacy-8.1 STATIC IMPORTED )
set_target_properties(vtkIOLegacy-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOLegacy-8.1.a)
add_library( vtkIOPLY-8.1 STATIC IMPORTED )
set_target_properties(vtkIOPLY-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOPLY-8.1.a)
add_library( vtkRenderingPLY-8.1 STATIC IMPORTED )
add_library( vtkIOXML-8.1 STATIC IMPORTED )
set_target_properties(vtkIOXML-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOXML-8.1.a)
add_library( vtkIOXMLParser-8.1 STATIC IMPORTED )
set_target_properties(vtkIOXMLParser-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkIOXMLParser-8.1.a)
add_library( vtkjpeg-8.1 STATIC IMPORTED )
set_target_properties(vtkjpeg-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkjpeg-8.1.a)
add_library( vtklibxml2-8.1 STATIC IMPORTED )
set_target_properties(vtklibxml2-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtklibxml2-8.1.a)
add_library( vtklz4-8.1 STATIC IMPORTED )
set_target_properties(vtklz4-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtklz4-8.1.a)
add_library( vtkmetaio-8.1 STATIC IMPORTED )
set_target_properties(vtkmetaio-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkmetaio-8.1.a)
add_library( vtkParallelCore-8.1 STATIC IMPORTED )
set_target_properties(vtkParallelCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkParallelCore-8.1.a)
add_library( vtkpng-8.1 STATIC IMPORTED )
set_target_properties(vtkpng-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkpng-8.1.a)
add_library( vtkRenderingCore-8.1 STATIC IMPORTED )
set_target_properties(vtkRenderingCore-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkRenderingCore-8.1.a)
add_library( vtkRenderingFreeType-8.1 STATIC IMPORTED )
set_target_properties(vtkRenderingFreeType-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkRenderingFreeType-8.1.a)
add_library( vtkRenderingOpenGL2-8.1 STATIC IMPORTED )
set_target_properties(vtkRenderingOpenGL2-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkRenderingOpenGL2-8.1.a)
add_library( vtkRenderingVolume-8.1 STATIC IMPORTED )
set_target_properties(vtkRenderingVolume-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkRenderingVolume-8.1.a)
add_library( vtkRenderingVolumeOpenGL2-8.1 STATIC IMPORTED )
set_target_properties(vtkRenderingVolumeOpenGL2-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkRenderingVolumeOpenGL2-8.1.a)
add_library( vtkglew-8.1 STATIC IMPORTED )
set_target_properties(vtkglew-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkglew-8.1.a)
add_library( vtksys-8.1 STATIC IMPORTED )
set_target_properties(vtksys-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtksys-8.1.a)
add_library( vtkTestingRendering-8.1 STATIC IMPORTED )
set_target_properties(vtkTestingRendering-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkTestingRendering-8.1.a)
add_library( vtktiff-8.1 STATIC IMPORTED )
set_target_properties(vtktiff-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtktiff-8.1.a)
add_library( vtkzlib-8.1 STATIC IMPORTED )
set_target_properties(vtkzlib-8.1 PROPERTIES IMPORTED_LOCATION ${JNIBASE}/libvtkzlib-8.1.a)



target_link_libraries(
            native-lib

            vtkCommonMath-8.1
            vtkRenderingCore-8.1
            vtkCommonMath-8.1
            vtkCommonTransforms-8.1
            vtkImagingCore-8.1
            vtkFiltersCore-8.1
            vtkFiltersSources-8.1
            vtkRenderingOpenGL2-8.1
            vtkRenderingCore-8.1
            vtkFiltersGeneral-8.1
            vtkCommonExecutionModel-8.1
            vtkCommonDataModel-8.1
            vtkCommonMath-8.1
            vtkCommonCore-8.1
            vtkCommonMisc-8.1

            vtksys-8.1
            vtkCommonColor-8.1
            vtkCommonSystem-8.1

           # included in the NDK.
           ${dl}
           ${z}
           ${android}
           ${EGL}
           ${GLSESv2}
           ${log-lib}
   )

include_directories(native-lib PUBLIC   ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp)
include_directories(native-lib PUBLIC   ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/vtk-8.1)
include_directories(native-lib PUBLIC   ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/vtk-8.1/vtklibxml2/libxml)
include_directories(native-lib PUBLIC   ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/vtk-8.1/vtkzlib)
include_directories(native-lib PUBLIC   ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/vtk-8.1/vtklz4)




*********************************************************************************************
Worldline SA/NV - Chaussee de Haecht 1442 Haachtsesteenweg
- 1130 Brussels - Belgium
RPM-RPR Bruxelles-Brussel - TVA-BTW BE 0418.547.872
Bankrekening-Compte Bancaire-Bank Account 310-0269424-44
BIC BBRUBEBB - IBAN BE55 3100 2694 2444

"The information contained in this e-mail and any attachment there to be confidential and may contain information which is protected by intellectual property rights.
This information is intended for the exclusive use of the recipient(s) named above.
This e-mail does not constitute any binding relationship or offer toward any of the addressees.
If you are not one of the addressees , one of their employees or a proxy holder entitled to hand over this message to the addressee(s), any use of the information contained herein (e.g. reproduction, divulgation, communication or distribution,...) is prohibited.
If you have received this message in error, please notify the sender and destroy it immediately after.
The integrity and security of this message cannot be guaranteed and it may be subject to data corruption, interception and unauthorized amendment, for which we accept no liability."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180201/8aed502b/attachment.html>


More information about the vtkusers mailing list