9

I have added libpng to my application. If I build for simulator, everything is OK. When I build application for device, I got linker error:

    Undefined symbols for architecture armv7: "_png_init_filter_functions_neon", referenced from: _png_read_filter_row in libpng-arm7-release.a(pngrutil.o)

I have build libpng manually from source, same way for simulator and device (only with changed target of compilation). I have tried to find this problem, but noone seems to post anything about this problem.

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
Martin Perry
  • 9,232
  • 8
  • 46
  • 114

3 Answers3

10

I "solved" this by replacing lines 117-121 in libpng's pngpriv.h:

#  ifdef __ARM_NEON__
#     define PNG_ARM_NEON_OPT 2
#  else
#     define PNG_ARM_NEON_OPT 0
#  endif

by

#define PNG_ARM_NEON_OPT 0

This disables ARM's NEON optimizations, which seems to be the cause of the problem.

This is merely a workaround though, I didn't have time to investigate the real cause of the problem further.

Guillaume Algis
  • 10,705
  • 6
  • 44
  • 72
1

Adding to PSyton's comment, here is how we solved it. Compile the arm/*.c files. This however does only work for Android. For iOS, we additionally had to create a new pnglibconf.h with the entries:

#undef PNG_ARM_NEON_API_SUPPORTED
#undef PNG_ARM_NEON_CHECK_SUPPORTED
#define PNG_ARM_NEON_OPT 0

Looking at the ARM defines in libpng, it seems like they are a bit buggy currently, as PNG_ARM_NEON_API_SUPPORTED should be sufficient to turn NEON compilation off.

abergmeier
  • 13,224
  • 13
  • 64
  • 120
1

I experienced a similar error on macOS. After getting libpng from the source https://sourceforge.net/projects/libpng/files/ and compiling with the PNG_ARM_NEON option off, the error disappeared.