gpt4 book ai didi

android - 在 Centos 7 上为 Android 交叉编译 protobuf 2.5.0

转载 作者:行者123 更新时间:2023-11-30 05:14:38 25 4
gpt4 key购买 nike

我想运行一个用 C++ 编写的 Qt 控制台应用程序,其中包括在 Android 手机上使用 protobuf。

因此,我需要为 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

而且我不确定我是否在构建正确的架构。我的手机支持ABI arm64-v8a、armeabi-v7a和armeabi,操作系统是android 6 marshmallow

我很感激你的每一个建议!

这是我的 config.log 文件的链接 enter link description here

最佳答案

我能够用这个 scipt 编译 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

关于android - 在 Centos 7 上为 Android 交叉编译 protobuf 2.5.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43368102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com