android开发----5.jni编译protobuf

2020阅读 0评论2017-02-28 wangcong02345
分类:Android平台

1. jni 编译protobuf
在源码下建立jni目录
  1. cong@msi:/work/cloud/mifi_arm/protobuf-2.5.0_jni$ tree jni/
  2. jni/
  3. ├── Android.mk
  4. └── Application.mk

2. Android.mk与Application.mk的内容如下
jni/Application.mk
  1. APP_MODULES := protobuf
  2. APP_PLATFORM := android-9
  3. APP_ABI := armeabi-v7a
  4. APP_STL := gnustl_static
  5. APP_OPTIM := release

  6. APP_CPPFLAGS := -fexceptions -frtti


jni/Android.mk
  1. LOCAL_PATH := $(call my-dir)
  2. SRC_PATH := ../src

  3. include $(CLEAR_VARS)

  4. LOCAL_CFLAGS:= -DHAVE_PTHREAD=1

  5. LOCAL_SRC_FILES:= \
  6.     $(SRC_PATH)/google/protobuf/io/coded_stream.cc \
  7.     $(SRC_PATH)/google/protobuf/stubs/common.cc \
  8.     $(SRC_PATH)/google/protobuf/descriptor.cc \
  9.     $(SRC_PATH)/google/protobuf/descriptor.pb.cc \
  10.     $(SRC_PATH)/google/protobuf/descriptor_database.cc \
  11.     $(SRC_PATH)/google/protobuf/dynamic_message.cc \
  12.     $(SRC_PATH)/google/protobuf/extension_set.cc \
  13.     $(SRC_PATH)/google/protobuf/extension_set_heavy.cc \
  14.     $(SRC_PATH)/google/protobuf/generated_message_reflection.cc \
  15.     $(SRC_PATH)/google/protobuf/generated_message_util.cc \
  16.     $(SRC_PATH)/google/protobuf/io/gzip_stream.cc \
  17.     $(SRC_PATH)/google/protobuf/compiler/importer.cc \
  18.     $(SRC_PATH)/google/protobuf/message.cc \
  19.     $(SRC_PATH)/google/protobuf/message_lite.cc \
  20.     $(SRC_PATH)/google/protobuf/stubs/once.cc \
  21.     $(SRC_PATH)/google/protobuf/compiler/parser.cc \
  22.     $(SRC_PATH)/google/protobuf/io/printer.cc \
  23.     $(SRC_PATH)/google/protobuf/reflection_ops.cc \
  24.     $(SRC_PATH)/google/protobuf/repeated_field.cc \
  25.     $(SRC_PATH)/google/protobuf/service.cc \
  26.     $(SRC_PATH)/google/protobuf/stubs/structurally_valid.cc \
  27.     $(SRC_PATH)/google/protobuf/stubs/strutil.cc \
  28.     $(SRC_PATH)/google/protobuf/stubs/substitute.cc \
  29.     $(SRC_PATH)/google/protobuf/text_format.cc \
  30.     $(SRC_PATH)/google/protobuf/io/tokenizer.cc \
  31.     $(SRC_PATH)/google/protobuf/unknown_field_set.cc \
  32.     $(SRC_PATH)/google/protobuf/wire_format.cc \
  33.     $(SRC_PATH)/google/protobuf/wire_format_lite.cc \
  34.     $(SRC_PATH)/google/protobuf/io/zero_copy_stream.cc \
  35.     $(SRC_PATH)/google/protobuf/io/zero_copy_stream_impl.cc \
  36.     $(SRC_PATH)/google/protobuf/io/zero_copy_stream_impl_lite.cc \
  37.     $(SRC_PATH)/google/protobuf/stubs/stringprintf.cc

  38. LOCAL_C_INCLUDES:= \
  39.     $(LOCAL_PATH)/../src \
  40.     $(LOCAL_PATH)/../

  41. LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lz
  42. LOCAL_SHARED_LIBRARIES:=
  43. LOCAL_MODULE:= protobuf
  44. LOCAL_MODULE_TAGS := optional

  45. include $(BUILD_SHARED_LIBRARY)

3. 这样就可以在protobuf-2.5.0的目录下编译了
上一篇:android开发----4.parser分析
下一篇:linux开发---28.【C】用libz库压缩与解压缩的测试