I am currently trying to build any recent version of VTK with any recent version of Android using:
cmake -S vtk -B vtk-android-build -GNinja -DVTK_ANDROID_BUILD=ON
cmake --build vtk-android-build
I have tried the following NDKs:
Along with the three
v8.0.2 tags as well as the current master for VTK with each of these.
For most Cartesian products, I am consistently getting the error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
linked by target "vtkRenderingOpenGL2" in directory /home/tt/kw/vtk/Rendering/OpenGL2
This post seems to suggest that NDK version r16b should work with VTK v8.0.2. However, with this configuration, I am getting the following error:
/home/tt/kw/vtk/Common/System/vtkTimerLog.cxx: In static member function 'static void vtkTimerLog::DumpLogWithIndentsAndPercentages(std::ostream*)':
/home/tt/kw/vtk/Common/System/vtkTimerLog.cxx:536:25: error: 'round' is not a member of 'std'
double percentage = std::round(elapsedTime / parent.second * 1000.) / 10.;
Is there a known build/NDK/SDK configuration that works?
I suspect the
std::round is due to a missing
<numeric> include directive.
master doesn’t seem to use
OPENGL_egl_LIBRARY anymore (though there are some vestiges in
vtkMobileDevices.cmake setting it, I don’t use uses of it).
#include <numerics> generates a subsequent error:
In file included from /home/tt/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/fstream:41:0,
/home/tt/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/cstdio:107:11: error: '::fgetpos' has not been declared
I’m guessing this build hasn’t been used or tested in awhile?
Yeah, it would seem so. Isn’t the NDK supposed to be using libc++ these days though?
This is an earlier version of the NDK:
i’m the author of the post you mentioned, build VTK with recent versions of NDK is still messy but i have retried it because NDK r16b was too old to be used for my own code and others dependencies.
I found another workaround to get VTK compiled with NDK r21e but this time without backend librairies if you don’t need to render things and use only others common functions. Here is the portion of my documentation with instructions:
# Install VTK (8.2.0) from sources
git clone https://github.com/Kitware/VTK.git
git checkout v8.2.0
# Manually disable those backend modules in CMake/vtkAndroid.cmake
mkdir build && cd build
cmake .. \
cp -r CMakeExternals/Install/vtk-android/* $ANDROID_ARM64_V8A_INSTALL_PREFIX
But i don’t giving up to make thoses backend librairies found by linker with recent NDK versions.
I hope this can help you.
For info, I am currently working on it. See https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8163
Still facing issues with some math functions (isnan, isfinite, etc).
Just updating here that the recent changes in !8163 once again allow VTK to be build for Android.