Я хочу использовать protobuf в нативном коде C ++ в Android. Я выполнил шаги, описанные в https://developers.google.com/cardboard/develop/c/protobuf. Но он застрял на кросс-компиляции protobuflib с:
/tmp/protobuf/../arm-21-toolchain-clang-32/sysroot/usr/lib/../lib/crtbegin_dynamic.o:crtbegin.c:function _start: error: undefined reference to 'main'
clang50++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [protoc] Error 1
и
CXXLD protoc
./.libs/libprotobuf.a: error adding symbols: Archive has no index; run ranlib to add one
clang50++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [protoc] Error 1
Я использую этот скрипт для сборки:
cd /tmp
### Cross-compile Protocol Buffers library ###
#git clone https://github.com/protocolbuffers/protobuf.git
cd /tmp/protobuf
git checkout v3.10.1
git submodule update --init --recursive
./autogen.sh
mkdir -p `pwd`/../libprotobuf/android
## buildscript32
export build_dir=`pwd`/../libprotobuf/android
export sysroot=`pwd`/../arm-21-toolchain-clang-32/sysroot
export PATH=`pwd`/../arm-21-toolchain-clang-32/bin:$PATH
export CC="arm-linux-androideabi-clang --sysroot $sysroot"
export CXX="arm-linux-androideabi-clang++ --sysroot $sysroot"
./configure \
--host=arm-linux-androideabi \
--with-protoc=protoc \
--with-sysroot="$sysroot" \
--disable-shared \
--prefix="$build_dir/armeabi-v7a" \
--enable-cross-compile \
CFLAGS="-march=armv7-a -D__ANDROID_API__=21" \
CXXFLAGS="-frtti -fexceptions -march=armv7-a -D__ANDROID_API__=21" \
LIBS="-llog -lz -lc++_static"
make -j8
make install
## clean
make distclean
## buildscript64
export build_dir=`pwd`/../libprotobuf/android
export sysroot=`pwd`/../arm-21-toolchain-clang-64/sysroot
export PATH=`pwd`/../arm-21-toolchain-clang-64/bin:$PATH
export CC="aarch64-linux-android-clang --sysroot $sysroot"
export CXX="aarch64-linux-android-clang++ --sysroot $sysroot"
./configure \
--host=arm-linux-androideabi \
--with-protoc=protoc \
--with-sysroot="$sysroot" \
--disable-shared \
--prefix="$build_dir/arm64-v8a" \
--enable-cross-compile \
CFLAGS="-march=armv8-a -D__ANDROID_API__=21" \
CXXFLAGS="-frtti -fexceptions -march=armv8-a -D__ANDROID_API__=21" \
LIBS="-llog -lz -lc++_static"
make -j8
make install
## generate file structure
mkdir -p ../libprotobuf/android/lib/armeabi-v7a
mkdir -p ../libprotobuf/android/lib/arm64-v8a
cp ../libprotobuf/android/armeabi-v7a/lib/libprotobuf-lite.a ../libprotobuf/android/lib/armeabi-v7a
cp ../libprotobuf/android/arm64-v8a/lib/libprotobuf-lite.a ../libprotobuf/android/lib/arm64-v8a
cp -r ../libprotobuf/android/armeabi-v7a/include ../libprotobuf/android/include
rm -rf ../libprotobuf/android/armeabi-v7a
rm -rf ../libprotobuf/android/arm64-v8a
### End: Cross-compile Protocol Buffers library ###
Как мне построить libprotobuf для Android ?? Хост: linux -x86_64 Спасибо