Wednesday, June 12, 2019

Build google protocol-buffer with NDK r19c

I was build google protocol buffer 3.30 with NDK r16 

It call the ./configure  pass in standalone toolchain as parameter, it works.

2 years later, the NDK upgrade to r19c
google protocol buffer upgrade to 3.8.0

When call ./configure same as previous version, report an error :

checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features by default... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with -std=c++11... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with +std=c++11... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with -h std=c++11... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with -std=c++0x... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with +std=c++0x... no
checking whether #ndk/toolchains/android/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ supports C++11 features with -h std=c++0x... no
configure: error: *** A compiler with support for C++11 language features is required.  

Finally, found solution: call cmake instead of ./autogen , ./configure

cd cmake
cmake \
-Dprotobuf_BUILD_SHARED_LIBS=OFF \
-Dprotobuf_BUILD_STATIC_LIBS=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_EXAMPLES=OFF \
-Dprotobuf_BUILD_PROTOC_BINARIES=OFF \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
-DANDROID_NDK=$ANDROID_NDK_ROOT \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=$androidabi \
-DANDROID_NATIVE_API_LEVEL=26 \
-DANDROID_STL=c++_shared \
-DANDROID_LINKER_FLAGS="-landroid -llog" \
-DANDROID_CPP_FEATURES="rtti exceptions" \
.
cmake --build .
make install

No comments:

Post a Comment