简体   繁体   English

为Android构建protobuf

[英]build protobuf for android

Refer to other one's topic, I do: 请参考其他人的主题,我这样做:

export ANDROID_ROOT=/home/jean/android-ndk-r8e
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/
./configure --host=arm-linux-androideabi CC=arm-linux-androideabi-gcc CPPFLAGS="-I$ANDROID_ROOT/platforms/android-9/arch-arm/usr/include/ -I$ANDROID_ROOT/sources/cxx-stl/gnu-libstdc++/4.7/include" CFLAGS="-nostdlib" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-9/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-9/arch-arm/usr/lib/" LIBS="-lc"

Configure success, but make report error, it says can not find bits/c++config.h in include path, I search this file, found it located in android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include/bits, so I copy it to android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/include and make again, another error: 配置成功,但报告错误,它说在包含路径中找不到bits / c ++ config.h,我搜索了此文件,发现它位于android-ndk-r8e / sources / cxx-stl / gnu-libstdc ++ / 4.7 / libs / armeabi / include / bits,所以我将其复制到android-ndk-r8e / sources / cxx-stl / gnu-libstdc ++ / 4.7 / include并再次创建,另一个错误:

/bin/bash ../libtool  --tag=CXX   --mode=compile arm-linux-androideabi-g++ -DHAVE_CONFIG_H -I. -I..   -I/home/jean/android-ndk-r8e/platforms/android-9/arch-arm/usr/include/ -I/home/jean/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/include  -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -O2 -g -DNDEBUG -MT common.lo -MD -MP -MF .deps/common.Tpo -c -o common.lo `test -f 'google/protobuf/stubs/common.cc' || echo './'`google/protobuf/stubs/common.cc
libtool: compile:  arm-linux-androideabi-g++ -DHAVE_CONFIG_H -I. -I.. -I/home/jean/android-ndk-r8e/platforms/android-9/arch-arm/usr/include/ -I/home/jean/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/include -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -O2 -g -DNDEBUG -MT common.lo -MD -MP -MF .deps/common.Tpo -c google/protobuf/stubs/common.cc  -fPIC -DPIC -o .libs/common.o
../libtool: line 1125: arm-linux-androideabi-g++: command not found
make[2]: *** [common.lo] Error 1

This is weird, I have add arm-linux-androideabi-g++ path to PATH and I input "arm-linux-androideabi-g++ --version" it works, why make can not find it? 这很奇怪,我在路径中添加了arm-linux-androideabi-g ++路径,并且输入了“ arm-linux-androideabi-g ++ --version”,它有效,为什么make找不到它?

BTW the configure will report error if I execute it with sudo or change to super user. 顺便说一句,如果我使用sudo执行或更改为超级用户,configure将报告错误。 The error is: 错误是:

checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
checking whether the C compiler works... no
configure: error: in `/home/jean/Dev/cpplibs/protobuf-2.5.0':
configure: error: C compiler cannot create executables

You need to add: 您需要添加:

CXX=arm-linux-androideabi-g++

at least to your arguments to configure . 至少要根据您的参数进行configure You may need to ad some CXXFLAGS as well. 您可能还需要添加一些CXXFLAGS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM