[vtk-developers] Constructing Android.mk files for ndk-build

Cameron Lowell Palmer cameron.palmer at ntnu.no
Mon Oct 27 09:31:00 EDT 2014

Bill, your email arrived as this was nearly finished.

I¹m not sure if you quite understand my issue. Getting VTK setup as a
static library was trivial. You simply allow the existing VES superbuild
to run and then roll up the contents of VTK using GNU ar.

In the stock KiwiViewer app cmake hands you a 9MB libKiwiNative.so and a
small amount of Java wrapping, but mostly the entire app lives in C++
land. This is undesirable since it turns your entire application into a
black box. I have documented the process on a Mac at

In our version of KiwiViewerApp, called SCViewerApp, we don¹t touch
vtk-android, but we customize ves-android which is comprised of ves/ and
kiwi/ C++ code. Cmake runs and again builds libSCNative.so. This is still
undesirable because you can¹t readily debug it and we¹re moving into a
more mobile specific phase of the project that will require it.

SoŠ I¹ve let the superbuild run normally and then generated a
libvtk-android.a file from the dozen or so resulting vtk .a files. Then I
copy this into the jni/ folder.

Now, the issue is getting the Android.mk file setup for VES, VTK
(PREBUILT_STATIC_LIBRARY), Kiwi, Eigen using ndk-build. That work is
located at https://github.com/palmerc/VES-Kiwi-NDK.

Now maybe I¹m missing something here, but I need to be able to set
breakpoints in the VES and Kiwi C++ code. As I see it this is the only
approach that is going to get me there. However, I¹m quite willing to be
wrong. :) 


On 27.10.14, 03.44, "Ben Boeckel" <ben.boeckel at kitware.com> wrote:

>On Sun, Oct 26, 2014 at 13:15:22 +0000, Cameron Lowell Palmer wrote:
>> Has anyone ever built Kiwi-VES using ndk-build and Android.mk? If so,
>> can we share?
>> My current strategy is to statically compile vtk-android and roll up
>> all the output of the vtk superbuild as a single libvtk-android.a.
>> I?ve used GNU ar to roll up all of the .a files. Then I?ll leave our
>> custom Kiwi and VES code as source. This will allow me to build the
>> NDK portion in the standard Android fashion. My current obstacle is
>> the compilation of libarchive which seems to be a requirement of our
>> kiwi code.
>> If anyone is interested it would be fairly trivial to try this with
>> unmodified VES-Kiwi and put it up on github. Just let me know.
>Here[1]'s a (non-Kitware related) project which uses ndk-build for the
>Android bits, but CMake for the main build. Basically, you cross compile
>using the NDK toolchain with CMake, then have the Android bits "install"
>the binaries you're interested as an "external" NDK library[2]. Making a
>"super" library of all the enabled modules shouldn't be too hard to do
>just in the android build (so that umpteen libraries don't need
>"installed"). No need to set up the entire Android.mk infrastructure for
>all of VTK.

More information about the vtk-developers mailing list