为android设计protobuf

时间:2013-06-07 09:35:38

标签: android android-ndk protocol-buffers cross-compiling automake

请参阅其他人的主题,我这样做:

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"

配置成功,但报告错误,它说在include路径中找不到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

这很奇怪,我已经为PATH添加了arm-linux-androideabi-g ++路径,我输入“arm-linux-androideabi -g ++ --version”它有效,为什么make找不到它?

顺便说一句 如果我使用sudo执行它或更改为超级用户,configure将报告错误。错误是:

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

1 个答案:

答案 0 :(得分:0)

您需要添加:

CXX=arm-linux-androideabi-g++

至少是你对configure的论点。您可能还需要刊登一些CXXFLAGS