本文介绍了Android的NDK:包括BUILD_SHARED_LIBRARY之前缺少LOCAL_MODULE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置以下的。

我已经创建了一个全新的Andr​​oid项目测试1,其中我已经添加了这2个文件:

I've created a fresh new Android project "Test1", in which I've added these 2 files:

c:\Workspace\Test1\jni\Android.mk
c:\Workspace\Test1\jni\ndkfoo.c

这是 Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := ndkfoo
LOCAL_SRC_FILES := ndkfoo.c
include $(BUILD_SHARED_LIBRARY)

但是当我尝试编译它,我得到这个错误:

But when I try to compile it, I get this error:

c:\Workspace\Test1\jni>ndk-build
c:/android-ndk-r10d/build/core/build-shared-library.mk:23: *** Android NDK: Missing LOCAL_MODULE before including BUILD_SHARED_LIBRARY in c:/Workspace/Test1//jni/Android.mk    .  Stop.

不过,我有一个 LOCAL_MODULE:在 Android.mk = ndkfoo 条款,所以我不明白为什么我收到这个错误!

But I do have a LOCAL_MODULE    := ndkfoo clause in Android.mk, so I don't understand why I am getting this error!

推荐答案

在的情况下发布这个其他一些可怜的灵魂试图直接从该教程复制/粘贴 - 有什么不对的空间就行了 LOCAL_MODULE:= ndkfoo

Posting this in case some other poor soul tries to copy/paste directly from that tutorial - there is something wrong with the spaces on the line LOCAL_MODULE := ndkfoo.

我想他们是不是正确的空间,但其与NDK的构建搞乱,因为我看着他们一个十六进制编辑器和一些奇怪的Uni code人物,他们均为0xC2 0XA0为0xC2 0XA0为0xC2 0XA0 而不是 0x20的0x20的0x20的0x20的(这是正常的空格)。

I think they are not proper spaces but some weird Unicode character which was messing with ndk-build, because I looked at them with a hex editor and they were 0xC2 0xA0 0xC2 0xA0 0xC2 0xA0 instead of 0x20 0x20 0x20 0x20 (which is normal spaces).

任何人从他们的教程复制都会有这样的错误,很遗憾。

Anyone copying from their tutorial will have this error, unfortunately.

如果您尝试从这里的问题应该OK复制,我想是这样莫名其妙地修复它们正常的空间,但在原来的网站,他们都是不可思议的Uni code的空间,这将导致 NDK的构建失败。

If you try to copy from the question here it should be OK, I think SO has somehow fixed them to normal spaces, but on the original site they are weird Unicode spaces that will cause ndk-build to fail.

编辑:显然这些都是 。我不知道如果这是真的,但我认为NDK的构建并不承认他们是空白,所以他们成了变量名的一部分,所以我定义了一个名为变量LOCAL_MODULE,而不是LOCAL_MODULE,这就是为什么有人抱怨变量是不确定的。

Apparently those are non-breaking spaces. I have no idea if it's true, but I think that ndk-build didn't recognize them as whitespace, so they became part of the variable name, so I was defining a variable called "LOCAL_MODULE ", instead of "LOCAL_MODULE", which is why it was complaining about the variable being undefined.

这篇关于Android的NDK:包括BUILD_SHARED_LIBRARY之前缺少LOCAL_MODULE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 16:34