首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ndk-build No rule to make target for protobuf

ndk-build No rule to make target for protobuf
EN

Stack Overflow用户
提问于 2017-11-29 23:33:59
回答 2查看 1.2K关注 0票数 0

我一直在尝试使用ndk-build来获取我的用于Android开发的protobuf库,但我总是遇到一些问题。我从另一个堆栈溢出线程获得了我的Android.mk文件,它似乎不能工作。我是.mk的新手,完全不知道自己在做什么。

我在这个问题上也找到了这个:Android NDK: No rule to make target

在那个帖子中,他们指出有一行代码末尾的空格太多,所以我梳理了自己的文件,但找不到问题的根源。我明白了:

代码语言:javascript
复制
make: *** No rule to make target `C:/Users/jkarr/Downloads/protobuf-
master/jni/google/protobuf/arena.cc', needed by 
`C:/Users/jkarr/Downloads/protobuf-master/obj/local/armeabi-
v7a/objs/protobuf/google/protobuf/arena.o'.  Stop.

这是我的Android.mk文件:

代码语言:javascript
复制
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
c_includes := $(LOCAL_PATH)
LOCAL_MODULE := libprotobuf

LOCAL_SRC_FILES := \
google/protobuf/arena.cc \
google/protobuf/arenastring.cc \
google/protobuf/extension_set.cc \
google/protobuf/generated_message_util.cc \
google/protobuf/io/coded_stream.cc \
google/protobuf/io/zero_copy_stream.cc \
google/protobuf/io/zero_copy_stream_impl_lite.cc \
google/protobuf/message_lite.cc \
google/protobuf/repeated_field.cc \
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
google/protobuf/stubs/bytestream.cc \
google/protobuf/stubs/common.cc \
google/protobuf/stubs/int128.cc \
google/protobuf/stubs/once.cc \
google/protobuf/stubs/status.cc \
google/protobuf/stubs/statusor.cc \
google/protobuf/stubs/stringpiece.cc \
google/protobuf/stubs/stringprintf.cc \
google/protobuf/stubs/structurally_valid.cc \
google/protobuf/stubs/strutil.cc \
google/protobuf/stubs/time.cc \
google/protobuf/wire_format_lite.cc \
google/protobuf/any.cc \
google/protobuf/any.pb.cc \
google/protobuf/api.pb.cc \
google/protobuf/compiler/importer.cc \
google/protobuf/compiler/parser.cc \
google/protobuf/descriptor.cc \
google/protobuf/descriptor.pb.cc \
google/protobuf/descriptor_database.cc \
google/protobuf/duration.pb.cc \
google/protobuf/dynamic_message.cc \
google/protobuf/empty.pb.cc \
google/protobuf/extension_set_heavy.cc \
google/protobuf/field_mask.pb.cc \
google/protobuf/generated_message_reflection.cc \
google/protobuf/io/gzip_stream.cc \
google/protobuf/io/printer.cc \
google/protobuf/io/strtod.cc \
google/protobuf/io/tokenizer.cc \
google/protobuf/io/zero_copy_stream_impl.cc \
google/protobuf/map_field.cc \
google/protobuf/message.cc \
google/protobuf/reflection_ops.cc \
google/protobuf/service.cc \
google/protobuf/source_context.pb.cc \
google/protobuf/struct.pb.cc \
google/protobuf/stubs/mathlimits.cc \
google/protobuf/stubs/substitute.cc \
google/protobuf/text_format.cc \
google/protobuf/timestamp.pb.cc \
google/protobuf/type.pb.cc \
google/protobuf/unknown_field_set.cc \
google/protobuf/util/field_comparator.cc \
google/protobuf/util/field_mask_util.cc \
google/protobuf/util/internal/datapiece.cc \
google/protobuf/util/internal/default_value_objectwriter.cc \
google/protobuf/util/internal/error_listener.cc \
google/protobuf/util/internal/field_mask_utility.cc \
google/protobuf/util/internal/json_escaping.cc \
google/protobuf/util/internal/json_objectwriter.cc \
google/protobuf/util/internal/json_stream_parser.cc \
google/protobuf/util/internal/object_writer.cc \
google/protobuf/util/internal/proto_writer.cc \
google/protobuf/util/internal/protostream_objectsource.cc \
google/protobuf/util/internal/protostream_objectwriter.cc \
google/protobuf/util/internal/type_info.cc \
google/protobuf/util/internal/type_info_test_helper.cc \
google/protobuf/util/internal/utility.cc \
google/protobuf/util/json_util.cc \
google/protobuf/util/message_differencer.cc \
google/protobuf/util/time_util.cc \
google/protobuf/util/type_resolver_util.cc \
google/protobuf/wire_format.cc \
google/protobuf/wrappers.pb.cc \
google/protobuf/compiler/code_generator.cc \
google/protobuf/compiler/command_line_interface.cc \
google/protobuf/compiler/cpp/cpp_enum.cc \
google/protobuf/compiler/cpp/cpp_enum_field.cc \
google/protobuf/compiler/cpp/cpp_extension.cc \
google/protobuf/compiler/cpp/cpp_field.cc \
google/protobuf/compiler/cpp/cpp_file.cc \
google/protobuf/compiler/cpp/cpp_generator.cc \
google/protobuf/compiler/cpp/cpp_helpers.cc \
google/protobuf/compiler/cpp/cpp_map_field.cc \
google/protobuf/compiler/cpp/cpp_message.cc \
google/protobuf/compiler/cpp/cpp_message_field.cc \
google/protobuf/compiler/cpp/cpp_primitive_field.cc \
google/protobuf/compiler/cpp/cpp_service.cc \
google/protobuf/compiler/cpp/cpp_string_field.cc \
google/protobuf/compiler/plugin.cc \
google/protobuf/compiler/plugin.pb.cc \
google/protobuf/compiler/python/python_generator.cc \
google/protobuf/compiler/ruby/ruby_generator.cc \
google/protobuf/compiler/subprocess.cc \
google/protobuf/compiler/zip_writer.cc \


LOCAL_CFLAGS := -D GOOGLE_PROTOBUF_NO_RTTI=1
LOCAL_CPPFLAGS := -std=c++11
LOCAL_C_INCLUDES = $(LOCAL_PATH)/android
LOCAL_C_INCLUDES += ${ANDROID_NDK}/sources/cxx-stl/gnu-        libstdc++/4.8/include
LOCAL_LDLIBS += -lz
LOCAL_EXPORT_LDLIBS += -lz
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_EXPORT_CPPFLAGS := $(LOCAL_CPPFLAGS)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)


include $(BUILD_SHARED_LIBRARY)

不确定您是否也需要我的应用程序文件,但不管怎样,它在这里:

代码语言:javascript
复制
APP_STL :=gnustl_shared # gnustl_static
NDK_TOOLCHAIN_VERSION := 4.9
APP_ABI := armeabi-v7a
LIBCXX_FORCE_REBUILD := true
APP_PLATFORM:=android-19
NDK_DEBUG:=1

编辑:作为一个次要问题,我这里的Android.mk能让我使用protobuf-lite吗?

EN

回答 2

Stack Overflow用户

发布于 2017-11-30 01:14:50

我弄明白了为什么它会给我这个错误。我找错文件夹了。修复后的代码如下:

代码语言:javascript
复制
LOCAL_PATH := $(call my-dir)\src

现在我有了一个完全不同的问题。我收到错误消息:

代码语言:javascript
复制
[armeabi-v7a] Compile++ thumb: protobuf <= common.cc
C:/Users/jkarr/Downloads/protobuf-
3.5.0/jni\src/google/protobuf/stubs/common.cc:52:2: error: #error "No 
suitable threading library available."
#error "No suitable threading library available."
^
make: *** [C:/Users/jkarr/Downloads/protobuf-3.5.0/obj/local/armeabi-
v7a/objs/protobuf/google/protobuf/stubs/common.o] Error 1

我不知道从哪里开始做这个。

票数 0
EN

Stack Overflow用户

发布于 2018-02-08 10:25:23

假设你正在关注这篇文章https://stackoverflow.com/a/43729661/3845809,有几件事会导致问题。主要的问题是,这篇文章描述了如何构建v3.2,而您正在尝试构建v3.5。如果您可以使用v3.2,那么修复此问题的最简单方法是在post中的步骤2之前检查protobuf中的3.2.x分支。

为了构建用于NDK的v3.5,您需要在Android.mk文件中进行一些更新。以下是更新后的Android.mk

代码语言:javascript
复制
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
c_includes := $(LOCAL_PATH)
LOCAL_MODULE := libprotobuf

LOCAL_SRC_FILES := \
google/protobuf/arena.cc \
google/protobuf/arenastring.cc \
google/protobuf/extension_set.cc \
google/protobuf/generated_message_util.cc \
google/protobuf/io/coded_stream.cc \
google/protobuf/io/zero_copy_stream.cc \
google/protobuf/io/zero_copy_stream_impl_lite.cc \
google/protobuf/message_lite.cc \
google/protobuf/repeated_field.cc \
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
google/protobuf/stubs/bytestream.cc \
google/protobuf/stubs/common.cc \
google/protobuf/stubs/int128.cc \
google/protobuf/stubs/once.cc \
google/protobuf/stubs/status.cc \
google/protobuf/stubs/statusor.cc \
google/protobuf/stubs/stringpiece.cc \
google/protobuf/stubs/stringprintf.cc \
google/protobuf/stubs/structurally_valid.cc \
google/protobuf/stubs/strutil.cc \
google/protobuf/stubs/time.cc \
google/protobuf/wire_format_lite.cc \
google/protobuf/any.cc \
google/protobuf/any.pb.cc \
google/protobuf/api.pb.cc \
google/protobuf/compiler/importer.cc \
google/protobuf/compiler/parser.cc \
google/protobuf/descriptor.cc \
google/protobuf/descriptor.pb.cc \
google/protobuf/descriptor_database.cc \
google/protobuf/duration.pb.cc \
google/protobuf/dynamic_message.cc \
google/protobuf/empty.pb.cc \
google/protobuf/extension_set_heavy.cc \
google/protobuf/field_mask.pb.cc \
google/protobuf/generated_message_reflection.cc \
google/protobuf/io/gzip_stream.cc \
google/protobuf/io/printer.cc \
google/protobuf/io/strtod.cc \
google/protobuf/io/tokenizer.cc \
google/protobuf/io/zero_copy_stream_impl.cc \
google/protobuf/map_field.cc \
google/protobuf/message.cc \
google/protobuf/reflection_ops.cc \
google/protobuf/service.cc \
google/protobuf/source_context.pb.cc \
google/protobuf/struct.pb.cc \
google/protobuf/stubs/mathlimits.cc \
google/protobuf/stubs/substitute.cc \
google/protobuf/text_format.cc \
google/protobuf/timestamp.pb.cc \
google/protobuf/type.pb.cc \
google/protobuf/unknown_field_set.cc \
google/protobuf/util/field_comparator.cc \
google/protobuf/util/field_mask_util.cc \
google/protobuf/util/internal/datapiece.cc \
google/protobuf/util/internal/default_value_objectwriter.cc \
google/protobuf/util/internal/error_listener.cc \
google/protobuf/util/internal/field_mask_utility.cc \
google/protobuf/util/internal/json_escaping.cc \
google/protobuf/util/internal/json_objectwriter.cc \
google/protobuf/util/internal/json_stream_parser.cc \
google/protobuf/util/internal/object_writer.cc \
google/protobuf/util/internal/proto_writer.cc \
google/protobuf/util/internal/protostream_objectsource.cc \
google/protobuf/util/internal/protostream_objectwriter.cc \
google/protobuf/util/internal/type_info.cc \
google/protobuf/util/internal/type_info_test_helper.cc \
google/protobuf/util/internal/utility.cc \
google/protobuf/util/json_util.cc \
google/protobuf/util/message_differencer.cc \
google/protobuf/util/time_util.cc \
google/protobuf/util/type_resolver_util.cc \
google/protobuf/wire_format.cc \
google/protobuf/wrappers.pb.cc \
google/protobuf/compiler/code_generator.cc      \
google/protobuf/compiler/command_line_interface.cc      \
google/protobuf/compiler/cpp/cpp_enum.cc      \
google/protobuf/compiler/cpp/cpp_enum_field.cc      \
google/protobuf/compiler/cpp/cpp_extension.cc      \
google/protobuf/compiler/cpp/cpp_field.cc      \
google/protobuf/compiler/cpp/cpp_file.cc      \
google/protobuf/compiler/cpp/cpp_generator.cc      \
google/protobuf/compiler/cpp/cpp_helpers.cc      \
google/protobuf/compiler/cpp/cpp_map_field.cc      \
google/protobuf/compiler/cpp/cpp_padding_optimizer.cc      \
google/protobuf/compiler/cpp/cpp_message.cc      \
google/protobuf/compiler/cpp/cpp_message_field.cc      \
google/protobuf/compiler/cpp/cpp_primitive_field.cc      \
google/protobuf/compiler/cpp/cpp_service.cc      \
google/protobuf/compiler/cpp/cpp_string_field.cc      \
google/protobuf/compiler/plugin.cc      \
google/protobuf/compiler/plugin.pb.cc      \
google/protobuf/compiler/python/python_generator.cc      \
google/protobuf/compiler/ruby/ruby_generator.cc      \
google/protobuf/compiler/subprocess.cc      \
google/protobuf/compiler/zip_writer.cc      \


LOCAL_CFLAGS := -D GOOGLE_PROTOBUF_NO_RTTI=1
LOCAL_CPPFLAGS := -std=c++11 -D HAVE_PTHREAD=1 -frtti
LOCAL_C_INCLUDES = $(LOCAL_PATH)/android
LOCAL_C_INCLUDES += ${ANDROID_NDK}/sources/cxx-stl/gnu-        libstdc++/4.8/include
LOCAL_LDLIBS += -lz -llog
LOCAL_EXPORT_LDLIBS += -lz
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_EXPORT_CPPFLAGS := $(LOCAL_CPPFLAGS)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)


include $(BUILD_SHARED_LIBRARY)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47556410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档