To build libpng on iOS, I use CMake to generate an Xcode project and use the iOS toolchain located here:
https://github.com/leetal/ios-cmake
My CMake command:
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DIOS_ARCH="armv7 armv7s" -DENABLE_BITCODE=FALSE ..
My build command:
cmake --build . --config Release
When libpng links with any of my executables that uses it, I get this linker error:
Undefined symbols for architecture armv7:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in libpng16.a(pngrutil.o)
ld: symbol(s) not found for architecture armv7
The libpng CMakeLists.txt file has a section for png hardware optimizations. Looks like neon is made available for arm processors. However CMAKE_SYSTEM_PROCESSOR is blank in my iOS build so I can't enable or disable it. I noticed in my Android builds that variable isn't set either, but I don't run into the same build problem.
To work around this, I set the following in the toolchain file:
set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "")
After that, I get this error:
The following build commands failed:
CompileC /Users/steve/Documents/games_ios_build/3rdparty/libpng/libpng-1.6.34/Games.build/Release-iphoneos/png_static.build/Objects-normal/armv7/arm_init.o /Users/steve/Documents/games_ios_build/3rdparty/libpng/libpng-1.6.34/arm/arm_init.c normal armv7 c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
To work around that, I decide to just disable neon by putting this in CMakeLists.txt file upstream of the png CMake:
if(IOS)
set(PNG_ARM_NEON off CACHE STRING "")
endif()
Now everything builds and the program runs fine. I'm ok with this workaround, but I wanted to bring this to your attention in case you have a more robust fix in mind.
Forgot to mention I experienced this issue with version 1.6.34.