android-ndk – 如何通过Android NDK构建协议缓冲区

前端之家收集整理的这篇文章主要介绍了android-ndk – 如何通过Android NDK构建协议缓冲区前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想建一个本机版的Google协议缓冲库.
我该怎么办?

解决方法

我使用这个 Android.mk并构建SUCCESSFUL
  1. # Copyright (C) 2009 The Android Open Source Project
  2. #
  3. # Licensed under the Apache License,Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing,software
  10. # distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
  11. # See the License for the specific language governing permissions and
  12. # limitations under the License.
  13. #
  14. #
  15.  
  16. LOCAL_PATH := $(call my-dir)
  17. include $(CLEAR_VARS)
  18. CC_LITE_SRC_FILES := \
  19. src/google/protobuf/stubs/common.cc \
  20. src/google/protobuf/stubs/once.cc \
  21. src/google/protobuf/stubs/hash.cc \
  22. src/google/protobuf/extension_set.cc \
  23. src/google/protobuf/generated_message_util.cc \
  24. src/google/protobuf/message_lite.cc \
  25. src/google/protobuf/repeated_field.cc \
  26. src/google/protobuf/wire_format_lite.cc \
  27. src/google/protobuf/io/coded_stream.cc \
  28. src/google/protobuf/io/zero_copy_stream.cc \
  29. src/google/protobuf/io/zero_copy_stream_impl_lite.cc
  30.  
  31.  
  32. COMPILER_SRC_FILES := \
  33. src/google/protobuf/descriptor.cc \
  34. src/google/protobuf/descriptor.pb.cc \
  35. src/google/protobuf/descriptor_database.cc \
  36. src/google/protobuf/dynamic_message.cc \
  37. src/google/protobuf/extension_set.cc \
  38. src/google/protobuf/extension_set_heavy.cc \
  39. src/google/protobuf/generated_message_reflection.cc \
  40. src/google/protobuf/generated_message_util.cc \
  41. src/google/protobuf/message.cc \
  42. src/google/protobuf/message_lite.cc \
  43. src/google/protobuf/reflection_ops.cc \
  44. src/google/protobuf/repeated_field.cc \
  45. src/google/protobuf/service.cc \
  46. src/google/protobuf/text_format.cc \
  47. src/google/protobuf/unknown_field_set.cc \
  48. src/google/protobuf/wire_format.cc \
  49. src/google/protobuf/wire_format_lite.cc \
  50. src/google/protobuf/compiler/code_generator.cc \
  51. src/google/protobuf/compiler/command_line_interface.cc \
  52. src/google/protobuf/compiler/importer.cc \
  53. src/google/protobuf/compiler/main.cc \
  54. src/google/protobuf/compiler/parser.cc \
  55. src/google/protobuf/compiler/plugin.cc \
  56. src/google/protobuf/compiler/plugin.pb.cc \
  57. src/google/protobuf/compiler/subprocess.cc \
  58. src/google/protobuf/compiler/zip_writer.cc \
  59. src/google/protobuf/compiler/cpp/cpp_enum.cc \
  60. src/google/protobuf/compiler/cpp/cpp_enum_field.cc \
  61. src/google/protobuf/compiler/cpp/cpp_extension.cc \
  62. src/google/protobuf/compiler/cpp/cpp_field.cc \
  63. src/google/protobuf/compiler/cpp/cpp_file.cc \
  64. src/google/protobuf/compiler/cpp/cpp_generator.cc \
  65. src/google/protobuf/compiler/cpp/cpp_helpers.cc \
  66. src/google/protobuf/compiler/cpp/cpp_message.cc \
  67. src/google/protobuf/compiler/cpp/cpp_message_field.cc \
  68. src/google/protobuf/compiler/cpp/cpp_primitive_field.cc \
  69. src/google/protobuf/compiler/cpp/cpp_service.cc \
  70. src/google/protobuf/compiler/cpp/cpp_string_field.cc \
  71. src/google/protobuf/compiler/java/java_enum.cc \
  72. src/google/protobuf/compiler/java/java_enum_field.cc \
  73. src/google/protobuf/compiler/java/java_extension.cc \
  74. src/google/protobuf/compiler/java/java_field.cc \
  75. src/google/protobuf/compiler/java/java_file.cc \
  76. src/google/protobuf/compiler/java/java_generator.cc \
  77. src/google/protobuf/compiler/java/java_helpers.cc \
  78. src/google/protobuf/compiler/java/java_message.cc \
  79. src/google/protobuf/compiler/java/java_message_field.cc \
  80. src/google/protobuf/compiler/java/java_primitive_field.cc \
  81. src/google/protobuf/compiler/java/java_service.cc \
  82. src/google/protobuf/compiler/javamicro/javamicro_enum.cc \
  83. src/google/protobuf/compiler/javamicro/javamicro_enum_field.cc \
  84. src/google/protobuf/compiler/javamicro/javamicro_field.cc \
  85. src/google/protobuf/compiler/javamicro/javamicro_file.cc \
  86. src/google/protobuf/compiler/javamicro/javamicro_generator.cc \
  87. src/google/protobuf/compiler/javamicro/javamicro_helpers.cc \
  88. src/google/protobuf/compiler/javamicro/javamicro_message.cc \
  89. src/google/protobuf/compiler/javamicro/javamicro_message_field.cc \
  90. src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc \
  91. src/google/protobuf/compiler/python/python_generator.cc \
  92. src/google/protobuf/io/coded_stream.cc \
  93. src/google/protobuf/io/gzip_stream.cc \
  94. src/google/protobuf/io/printer.cc \
  95. src/google/protobuf/io/tokenizer.cc \
  96. src/google/protobuf/io/zero_copy_stream.cc \
  97. src/google/protobuf/io/zero_copy_stream_impl.cc \
  98. src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
  99. src/google/protobuf/stubs/common.cc \
  100. src/google/protobuf/stubs/hash.cc \
  101. src/google/protobuf/stubs/once.cc \
  102. src/google/protobuf/stubs/structurally_valid.cc \
  103. src/google/protobuf/stubs/strutil.cc \
  104. src/google/protobuf/stubs/substitute.cc
  105.  
  106. # C++ full library
  107. # =======================================================
  108. #include $(CLEAR_VARS)
  109.  
  110. LOCAL_MODULE := libprotobuf
  111. LOCAL_MODULE_TAGS := optional
  112.  
  113. LOCAL_CPP_EXTENSION := .cc
  114.  
  115. LOCAL_SRC_FILES := \
  116. $(CC_LITE_SRC_FILES) \
  117. src/google/protobuf/stubs/strutil.cc \
  118. src/google/protobuf/stubs/substitute.cc \
  119. src/google/protobuf/stubs/structurally_valid.cc \
  120. src/google/protobuf/descriptor.cc \
  121. src/google/protobuf/descriptor.pb.cc \
  122. src/google/protobuf/descriptor_database.cc \
  123. src/google/protobuf/dynamic_message.cc \
  124. src/google/protobuf/extension_set_heavy.cc \
  125. src/google/protobuf/generated_message_reflection.cc \
  126. src/google/protobuf/message.cc \
  127. src/google/protobuf/reflection_ops.cc \
  128. src/google/protobuf/service.cc \
  129. src/google/protobuf/text_format.cc \
  130. src/google/protobuf/unknown_field_set.cc \
  131. src/google/protobuf/wire_format.cc \
  132. src/google/protobuf/io/gzip_stream.cc \
  133. src/google/protobuf/io/printer.cc \
  134. src/google/protobuf/io/tokenizer.cc \
  135. src/google/protobuf/io/zero_copy_stream_impl.cc \
  136. src/google/protobuf/compiler/importer.cc \
  137. src/google/protobuf/compiler/parser.cc
  138.  
  139. LOCAL_C_INCLUDES := \
  140. $(LOCAL_PATH)/src
  141.  
  142. LOCAL_C_INCLUDES := \
  143. $(LOCAL_PATH)/android \
  144. bionic \
  145. $(LOCAL_PATH)/src \
  146. $(JNI_H_INCLUDE)
  147.  
  148. LOCAL_SHARED_LIBRARIES := \
  149. libz libcutils libutils
  150. LOCAL_LDLIBS := -lz
  151. # stlport conflicts with the host stl library
  152. ifneq ($(TARGET_SIMULATOR),true)
  153. LOCAL_C_INCLUDES += external/stlport/stlport
  154. LOCAL_SHARED_LIBRARIES += libstlport
  155. endif
  156.  
  157. # Define the header files to be copied
  158. #LOCAL_COPY_HEADERS := \
  159. # src/google/protobuf/stubs/once.h \
  160. # src/google/protobuf/stubs/common.h \
  161. # src/google/protobuf/io/coded_stream.h \
  162. # src/google/protobuf/generated_message_util.h \
  163. # src/google/protobuf/repeated_field.h \
  164. # src/google/protobuf/extension_set.h \
  165. # src/google/protobuf/wire_format_lite_inl.h
  166. #
  167. #LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
  168.  
  169. LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI
  170.  
  171. include $(BUILD_SHARED_LIBRARY)

猜你在找的Android相关文章