2017-04-12 145 views
1

我想運行一個用C++編寫的Qt控制檯應用程序,其中包括在android手機上使用protobuf。在Centos 7上爲Android安裝交叉編譯protobuf 2.5.0

因此,我需要爲arm架構交叉編譯protobuf。我一直在關注這個腳本。

https://gist.github.com/helayzhang/9034454

這是我的配置命令:

sudo ./configure --prefix=/home/staff/Desktop/proto_arm --build=armv7- android-linux-android --host=armv7-android-linux-android --target=armv7-android-linux-android --enable-cross-compile --with-protoc=/home/staff/Desktop/proto_arm/protoc CXXFLAGS="$(pkg-config --cflags protobuf)" LIBS="$(pkg-config --libs protobuf)" 

我的問題是交叉編譯選項被忽略

checking whether we are cross compiling... no 

,我不知道我是否建立了正確的建築。我的手機支持ABIs arm64-v8a,armeabi-v7a和armeabi,操作系統是android 6棉花糖

我很感謝每一個建議!

這裏是我的config.log文件的鏈接 enter link description here

+0

告訴我們您的配置腳本日誌或位置 – sailfish009

+0

我添加了一個鏈接描述中的config.log –

回答

1

我能夠編譯protobuf的這個素文字:

#!/bin/bash 
export NDK=/media/qt5-qwt6/ndk10/android-ndk-r10e 
export SYSROOT=$NDK/platforms/android-21/arch-arm 

export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 

export PATH=$PATH:$TOOLCHAIN/bin 

export CC="$TOOLCHAIN/bin/arm-linux-androideabi-gcc --sysroot $SYSROOT" 
export CXX="$TOOLCHAIN/bin/arm-linux-androideabi-g++ --sysroot $SYSROOT" 
export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.9 

function build_one 
{ 
mkdir build 

./configure --prefix=$(pwd)/build \ 
--host=arm-linux-androideabi \ 
--with-sysroot=$SYSROOT \ 
--enable-static \ 
--disable-shared \ 
--enable-cross-compile \ 
--with-protoc=protoc \ 
CFLAGS="-march=armv7-a" \ 
CXXFLAGS="-march=armv7-a -I$CXXSTL/include -I$CXXSTL/libs/armeabi-v7a/include -L$CXXSTL/libs/armeabi-v7a/ -lgnustl_static" 

make clean 
make 
make install 
} 

CPU=arm 
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm" 
build_one 

# Inspect the library architecture specific information 
# arm-linux-androideabi-readelf -A build/lib/libprotobuf-lite.a