【发布时间】:2015-01-21 10:51:39
【问题描述】:
我正在尝试构建本机应用程序以仅从命令行(adb shell)使用它。我尝试使用 ndk-build 构建它(不创建项目)。这是我的代码 Application.mk
APP_ABI := all
应用程序.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test.and
LOCAL_SRC_FILES := main.cpp
LOCAL_CPPFLAGS := -std=gnu++0x -Wall # whatever g++ flags you like
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog # whatever ld flags you like
include $(BUILD_EXECUTABLE) # <-- Use this to build an executable.
main.cpp
#include <stdio.h>//for printf
#include <stdlib.h>//for exit
int main(int argc, char **argv)
{
int i = 1;
i+=2;
printf("Hello, world (i=%d)!\n", i);
return 0;
exit(0);
}
我收到下一个错误
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/home/crosp/.AndroidStudioBeta/android-ndk-cr/build/core/build-local.mk:130: *** Android NDK: Aborting . Stop.
有什么方法可以在不创建项目的情况下编译它,我根本不需要项目,我只想编写没有 GUI 的本机应用程序并在 Java 应用程序中使用本机代码。 提前感谢您的帮助。
【问题讨论】:
标签: android c android-ndk