# png Android linking problem

**URL:** https://discourse.vtk.org/t/png-android-linking-problem/1311
**Category:** Development
**Created:** [July 9, 2019, 11:46am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311 "2019-07-09T11:46:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hcwiley](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hcwiley/32/638_2.png) [@hcwiley](https://discourse.vtk.org/u/hcwiley)
#### Post date: [July 9, 2019, 11:46am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/1 "2019-07-09T11:46:43Z")

</div>

There is a bug with linking to `vtkpng` after compiling for arm64-v8a with Android NDK 18b. I’m linking against vtk-8.2.0 arm64-v8a with another project that uses NEON and has flags specifying that. The linking error is:

```
undefined reference to `png_init_filter_functions_neon'

```

I suggest looking at how OpenCV is handling their 3rd party lib png: requirements:

```
if(ENABLE_NEON)
  list(APPEND lib_srcs arm/arm_init.c arm/filter_neon.S arm/filter_neon_intrinsics.c)
  add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(AARCH64)
  add_definitions(-DPNG_ARM_NEON_OPT=0) # NEON assembler is not supported
endif()

```

[See repo here](https://github.com/opencv/opencv/blob/bdaab1cee59d20916fb659fa37186af9e39da076/3rdparty/libpng/CMakeLists.txt#L31)

Not sure the VTK way to go about changing `vtkpng` to adopt some of these Android specific NEON changes. @ken-martin thoughts?

Just to get my problems sorted out I put `add_definitions(-DPNG_ARM_NEON_OPT=0)` at the top `vtkpng/CMakeLists.txt`. After doing that and recompiling VTK my linker error with the other project goes away.

---

<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: [July 9, 2019, 1:26pm UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/2 "2019-07-09T13:26:13Z")

</div>

We patch our PNG import to disable all optimization bits (our copies tend to be bare-bones and minimal for ease of porting the build system). We have `ThirdParty/png/vtkpng/pngpriv.h:#define PNG_ARM_NEON_OPT 0`. Is there a reason this isn’t working for you? It does work on our Android dashboard AFAICT: [https://open.cdash.org/buildSummary.php?buildid=5996639](https://open.cdash.org/buildSummary.php?buildid=5996639)

---

<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: [July 9, 2019, 1:30pm UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/3 "2019-07-09T13:30:29Z")

</div>

Oh, I see the `8.2.0` now. It is certainly possible that such a thing is missing on the `release-8.2` branch.

---

<div class="post-metadata">

### Author: ![hcwiley](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hcwiley/32/638_2.png) [@hcwiley](https://discourse.vtk.org/u/hcwiley)
#### Post date: [July 10, 2019, 5:58am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/4 "2019-07-10T05:58:01Z")

</div>

It’s also not a build problem, it builds just fine on my machine as well. It only presents itself when being linked against by another Android project.

I’ll see about updating my [Android example](https://github.com/Scandy-co/AndroidVTK) to show you.

---

<div class="post-metadata">

### Author: ![Harry\_Potter](https://discourse.vtk.org/user_avatar/discourse.vtk.org/harry_potter/32/1528_2.png) [@Harry\_Potter](https://discourse.vtk.org/u/Harry_Potter)
#### Post date: [March 24, 2020, 5:09am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/5 "2020-03-24T05:09:49Z")

</div>

I cannot build vtk on the jetson nano for the issue. VTK-8.2.0-release

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/b1ae8031ec9431851673cc2a12429e81fcb8fcac.png)  
Any way to repair it?

---

<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: [March 24, 2020, 5:15am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/6 "2020-03-24T05:15:58Z")

</div>

Please do not post image of code.

> <https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557>

  
[http://idownvotedbecau.se/imageofcode](http://idownvotedbecau.se/imageofcode)

---

<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: [March 24, 2020, 11:44am UTC](https://discourse.vtk.org/t/png-android-linking-problem/1311/7 "2020-03-24T11:44:26Z")

</div>

This was fixed on `master`, but I don’t think it made it onto the 8.2 release branch. Here’s the diff you need: [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/5603/diffs](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/5603/diffs)
