png Android linking problem

(H Cole Wiley) #1

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:

  list(APPEND lib_srcs arm/arm_init.c arm/filter_neon.S arm/filter_neon_intrinsics.c)
  add_definitions(-DPNG_ARM_NEON_OPT=0) # NEON assembler is not supported

See repo here

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.

(Ben Boeckel) #2

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:

(Ben Boeckel) #3

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

(H Cole Wiley) #4

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 to show you.