如何建立一个本地(命令行)执行在Android上运行吗?建立一个、命令行、Android

由网友(吴家可归i)分享简介:我已经受够了建立一个Android应用程序(GUI)的成功,采用的是原生(JNI)库。I've had success with building an Android app (GUI) that uses a native (JNI) library.不过,现在我想创建一个运行在命令行(root权限),不使用图...

我已经受够了建立一个Android应用程序(GUI)的成功,采用的是原生(JNI)库。

I've had success with building an Android app (GUI) that uses a native (JNI) library.

不过,现在我想创建一个运行在命令行(root权限),不使用图形用户界面在所有的可执行文件。如何建立类似的东西?

However, now I would like to create an executable that runs from the command line (root privileges) and does not use a GUI at all. How do I build something like that?

推荐答案

随着NDK r8d的,这可以在一个更简单的方法解决了。

As of NDK r8d, this can be solved in a much simpler way.

创建与下面的目录层次结构中的项目:

Create a project with the following directory hierarchy:

project/
    jni/
        Android.mk
        Application.mk
        *.c, *.cpp, *.h, etc.

在Android.mk中填写以下内容。最重要的是最后一行。检查NDK的文档的其他变量的含义。

怎么创建第一个Android工程,并运行应用程序

Fill in Android.mk with the following content. The most important thing is the last line. Check the NDK doc for the meaning of the other variables.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := name-of-your-executable
LOCAL_SRC_FILES := a.cpp b.cpp c.cpp etc.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.

转到项目/ 目录,只需键入

Go to the project/ directory, and simply type

ndk-build

结果将被放置在项目/库/&LT;弓&GT; /名称中,您可执行

阅读全文

相关推荐

最新文章