如何通过Android NDK构建协议缓冲区
我想构建 Google 协议缓冲区库的本机版本。
我该怎么做呢?
I want to built a native version of Google's protocol buffers library.
How would I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用这个 Android.mk 并成功构建
I Use this Android.mk and build SUCCESSFUL
上面提到的 Android.mk 工作正常,非常感谢。
我想描述一下为 android 构建 protobuf 的所有步骤。
配置 Android 源。
使用以下脚本(在这里获取:http://habrahabr.ru/post/119693/) :
PREBUILT=/Users/user/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3
PLATFORM=/Users/user/android-ndk-r7b/platforms/android-3/arch-arm/
导出 CC="/Users/user/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc"
导出 CFLAGS="-fPIC -DANDROID -nostdlib"
导出 ANDROID_ROOT="/Users/user/android-ndk-r7b"
export LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib /”
导出 CPPFLAGS="-I$ANDROID_ROOT/platforms/android-3/arch-arm/usr/include/"
导出 LIBS="-lc"
./configure --host=arm-eabi
从上面删除以下行Android.mk文件:
构建精简版库需要它。
不幸的是,该库的完整版本仅适用于 Android 2.3。
我测试了 Android 1.6、2.1、2.3 的精简版。
Android.mk mentioned above works fine, thanks a lot.
I would like to describe all the steps for building protobuf for android.
Configure sources for android.
Use the following script (got it here: http://habrahabr.ru/post/119693/):
PREBUILT=/Users/user/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3
PLATFORM=/Users/user/android-ndk-r7b/platforms/android-3/arch-arm/
export CC="/Users/user/android-ndk-r7b/toolchains/arm-linux-androideabi- 4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc"
export CFLAGS="-fPIC -DANDROID -nostdlib"
export ANDROID_ROOT="/Users/user/android-ndk-r7b"
export LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib/"
export CPPFLAGS="-I$ANDROID_ROOT/platforms/android-3/arch-arm/usr/include/"
export LIBS="-lc "
./configure --host=arm-eabi
Delete the following lines from mentioned above Android.mk file:
It is needed for building lite version of library.
Unfortunately full version of the lib works just from Android 2.3.
I tested lite version for Android 1.6, 2.1, 2.3.