0
我正嘗試構建本地應用程序以僅從命令行(adb shell)使用它。我試圖使用ndk-build(不創建項目)來構建它。這裏是我的代碼Application.mk在不創建項目的情況下構建NDK源碼
APP_ABI := all
Application.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應用程序中使用本機代碼。 感謝您的幫助。
如果您在jni/Application.mk中設置APP_PLATFORM:= android-16(或更高版本)或APP_PIE:= true,則不需要手動設置PIE選項(儘管對於此示例,一個額外的文件)。 – mstorsjo 2014-11-24 07:43:25
@mstorsjo:是的,的確,這可以做到這一點。感謝您的意見。 – ozbek 2014-11-24 08:05:04
Thx !!作品!我不得不添加變量! – braohaufngec 2014-11-24 22:40:44