我是Android的新学习者,我正在尝试使用Ubuntu进行Android ndk演示。
我运行ndk-build并获得下面的结果。
andylee@ubuntu:~/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/sources/hello/jni$ ndk-build -C
/home/andylee/Downloads/android-ndk-r11-linux-x86_64.tar.bz2/sources/hello
make: Entering directory '/home/andylee/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/sources/hello'
make: *** No rule to make target '/hello.c', needed by
'obj/local/armeabi/objs/helloARM/hello.o'. Stop.
make: Leaving directory '/home/andylee/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/sources/hello'
然后我删除了另一个文件夹中的Android.mk(文件夹结构如下)并得到它。
andylee@ubuntu:~$ ndk-build -C /home/andylee/Downloads/android-ndk-r11-
linux-x86_64.tar.bz2/sources/hello
make: Entering directory '/home/andylee/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/sources/hello'
Android NDK: : Cannot find module with tag 'cxx-stl/system' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined
?
Android NDK: The following directories were searched:
Android NDK:
/home/andylee/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/build/core/setup-toolchain.mk:213: *** Android NDK: Aborting.
. Stop.
make: Leaving directory '/home/andylee/Downloads/android-ndk-r11-linux-
x86_64.tar.bz2/sources/hello'
我的文件夹结构是这样的。
home/andylee/Downloads/android-ndk-r11-linux-x86_64.tar.bz2
ndk-build
/sources
/cxx-stl
/system
/Android.mk
/hello
/jni
/hello.c
/hello.h
/Android.mk
jni文件夹中的Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := hello.c
LOCAL_MODULE := helloARM
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_FORCE_STATIC_EXECUTABLE := true
include $(BUILD_EXECUTABLE)
的hello.c
#include "hello.h"
int main(int argc, char *argv[]){
printf("Hello World!\n");
return 0;
}
hello.h
#ifndef HELLOHEADER_H_
#define HELLOHEADER_H_
#include <stdio.h>
#endif /*HELLOHEADER_H_*/
我想知道为什么ndk会找到带有'cxx-stl / system'标签的模块,我没有在Android.mk中导入任何模块。几个小时以来我一直很沮丧,我真的很感激你的帮助。
答案 0 :(得分:0)
当我从演示中复制这些代码时,似乎存在一些语法错误。纠正错误后我可以成功构建。