Search code examples
c++candroid-ndkcross-compilinglibpng

Problem with using the NDK with other build systems


I am learning Use the NDK with other build systems. Trying to get the example for Autoconf to work. It looks like ./configure --host $TARGET is working as expected. But I get an error while executing make:

arm/filter_neon.S  -fPIC -DPIC -o arm/.libs/filter_neon.o
arm/filter_neon.S:24:17: error: expected string in directive
.section __LLVM,__asm
                ^
make[1]: *** [Makefile:1187: arm/filter_neon.lo] Error 1

I am new to Android and Linux. Here is the .sh-file I am using on Ubuntu:

#!/bin/bash -v
# Check out the source.
git clone https://github.com/glennrp/libpng
cd libpng
# Only choose one of these, depending on your build machine...
#export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
# Only choose one of these, depending on your device...
#export TARGET=aarch64-linux-android
export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
#export TARGET=x86_64-linux-android
# Set this to your minSdkVersion.
export API=21
# Configure and build.
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
./configure --host $TARGET
make

What am I doing wrong, why the tutorial example doesn't work? Thank you in advance.


Solution

  • There are bug in libpng. Do not use cloning from github. Use released version. There are different link on github https://github.com/glennrp/libpng/releases/tag/v1.6.35

    Change this script from official doc and do not clone github repo, just download archive and run this script inside of it.

    For me all is working.