# Error Building VTK for Android

**URL:** https://discourse.vtk.org/t/error-building-vtk-for-android/6803
**Category:** Support
**Created:** [October 12, 2021, 12:08am UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803 "2021-10-12T00:08:33Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [October 12, 2021, 12:08am UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/1 "2021-10-12T00:08:33Z")

</div>

I am currently trying to build vtk for android using these commands:

```auto
cmake -S vtk-master -B vtk-android-build -DVTK_ANDROID_BUILD=ON
cmake --build vtk-android-build

```

The build is with the vtk version from the master branch, and android-ndk-r21e. The build runs smoothly up to 81%, then fails with the error below:

```auto
[81%] Performing configure step for 'vtk-android'
-- Android: Targeting API '27' with architecture 'arm', ABI 'armeabi', and processor 'armv5te'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 9.0.9
-- The CXX compiler identification is Clang 9.0.9
-- Check for working C compiler: /home/cmengich/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/cmengich/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/cmengich/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/cmengich/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could not use git to determine source version, using version
-- Setting build type to 'Debug' as none was specified.
CMake Error at CMake/vtkCrossCompiling.cmake:7 (find_package):
  Could not find a configuration file for package "VTKCompileTools" that is
  compatible with requested version "".

  The following configuration files were considered but not accepted:

    /home/cmengich/Software/vtk-android-build/CompileTools/vtkcompiletools-config.cmake, version: 9.1.20211011 (64bit)

Call Stack (most recent call first):
  CMakeLists.txt:57 (include)

-- Configuring incomplete, errors occurred!
See also "/home/cmengich/Software/vtk-android-build/CMakeExternals/Build/vtk-android-27-armeabi/CMakeFiles/CMakeOutput.log".
make[2]: *** [CMakeFiles/vtk-android.dir/build.make:108: CMakeExternals/Prefix/vtk-android-27-armeabi/src/vtk-android-stamp/vtk-android-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/vtk-android.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

```

Any suggestions as to how to get passed this error?  
Or any suggestions on the best way to build vtk for android that works?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 12, 2021, 6:34pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/2 "2021-10-12T18:34:25Z")

</div>

Hrm. It’d be nice if there were more information about why the `VTKCompileTools` package is not suitable. Does adding `--debug-find` to the `CMAKE_ARGS` in `CMake/vtkAndroid.cmake` for the `vtk-android` project give any more information?

---

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [October 12, 2021, 9:08pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/3 "2021-10-12T21:08:14Z")

</div>

Hi @ben.boeckel

Adding `--debug-find` to the `CMAKE_ARGS` in `CMake/vtkAndroid.cmake` produces the exact same error, no more information.

Following a search, I found a similar issue here: [https://gitlab.kitware.com/vtk/vtk/-/issues/17705](https://gitlab.kitware.com/vtk/vtk/-/issues/17705), that produces the same error.

Any ideas?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 12, 2021, 10:56pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/4 "2021-10-12T22:56:17Z")

</div>

Oh. It seems that CMake is upset that it found 64bit binaries for a 32bit build. It doesn’t know that these are host tools and the arch doesn’t need to match. The issue reported that adding `-m32` to the flags for the compiletools build seemed to work.

This is related to this thread:

[https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224/3](https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224/3)

---

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [October 13, 2021, 12:33pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/6 "2021-10-13T12:33:27Z")

</div>

Hi @ben.boeckel

Thanks for taking the time to help me out.

After installing the necessary libraries, I run the following:

```auto
cmake -S vtk-master -B vtk-android-build -DVTK_ANDROID_BUILD=ON -DCMAKE_CXX_FLAGS=-m32
cmake --build vtk-android-build

```

and still getting the same error.

```auto
CMake Error at CMake/vtkCrossCompiling.cmake:7 (find_package):
  Could not find a configuration file for package "VTKCompileTools" that is
  compatible with requested version "".

  The following configuration files were considered but not accepted:

    /home/cmengich/Software/vtk-android-build/CompileTools/vtkcompiletools-config.cmake, version: 9.1.20211011 (64bit)

```

What am I missing?

---

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [October 14, 2021, 12:37pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/7 "2021-10-14T12:37:31Z")

</div>

Hi @ben.boeckel  
I made some progress, and have gotten passed the error raised above.  
However, now the build gets to the point below and raises another error:

```auto
[2%] Detecting builtin compiler preprocessor defines for VTKCompileTools
clang++: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang++: warning: argument unused during compilation: '-mthumb' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-mfpu=vfpv3-d16' [-Wunused-command-line-argument]clang++: warning: argument unused during compilation: '-mfloat-abi=softfp' [-Wunused-command-line-argument]
error: unknown target CPU 'armv7-a'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64

```

Any ideas on how to get passed this?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [November 15, 2021, 9:06pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/8 "2021-11-15T21:06:30Z")

</div>

Sorry, no. @ken-martin have you done Android compilation recently?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [November 16, 2021, 7:58am UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/9 "2021-11-16T07:58:31Z")

</div>

FYI @Michael

---

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [November 16, 2021, 6:28pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/10 "2021-11-16T18:28:14Z")

</div>

Hi @ben.boeckel, the problem seems to be with the vtk master version.

I successfully built with vtk-8.2.0, with

```auto
cmake -S vtk-8.2.0 -B vtk-android -DVTK_ANDROID_BUILD=ON 
cmake --build vtk-android

```

All vtk-9 versions also raised errors when building.

Experienced the same with building for ios, built successfully with vtk-8.2.0.

---

<div class="post-metadata">

### Author: ![cmengich](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@cmengich](https://discourse.vtk.org/u/cmengich)
#### Post date: [November 16, 2021, 6:30pm UTC](https://discourse.vtk.org/t/error-building-vtk-for-android/6803/11 "2021-11-16T18:30:47Z")

</div>

I did have a follow-up question. How would one go about building for android/ios and include the wrap for python options?
