简体   繁体   English

android NDK构建问题

[英]android NDK build issue

when I tried the NDK build command here is the error i got 当我尝试NDK构建命令时,这是我得到的错误

        D:\AndroidWorkSpace\cppTestProj>D:\android-ndk-r8b-windows\android-ndk-r8b\ndk-b
uild.cmd
Android NDK: WARNING: Unsupported source file extensions in jni/Android.mk for m
odule cppTestProj
Android NDK:   LOCAL_SRC_FILES :=
"Compile++ thumb : cppTestProj <= maintestapp.cpp
jni/maintestapp.cpp:1:19: fatal error: iostream: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/cppTestProj/maintestapp.o] Error 1

The JNI folder has the following files: JNI文件夹包含以下文件:

maintestapp.cpp
Test_array_type.cpp
Test_array_type.h

Could u pls let me know the issue. 您能否让我知道这个问题。 Im not using Cygwin for the same. 我没有使用Cygwin。 Am I missing any files? 我是否缺少任何文件?

Here is the make file 这是make文件

    LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := cppTestProj
LOCAL_SRC_FILES := LOCAL_SRC_FILES := maintestapp.cpp \
                   Test_array_type.cpp

include $(BUILD_SHARED_LIBRARY)

here is the cpp file 这是cpp文件

#include<iostream>
#include"Test_array_type.h"
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
    Test_array_type test_array;
    Test_array_type *ptest_array1;

    test_array.AddToList(10);
    test_array.AddToList(20);
    test_array.AddToList("Basha");
    test_array.PrintList();
    ptest_array1 = test_array.clonelist();
    test_array.DeleteFromList(3);
    test_array.AddToList(10);
    test_array.AddToList(20);
    test_array.AddToList(30);
    test_array.AddToList(40);
    test_array.AddToList(true);
    test_array.AddToList("Java Beon APP");
    test_array.PrintList();
    ptest_array1->PrintList();
    getch();
    return true;
}

you should not run the 'ndk-build' command from your projects jni folder. 您不应在项目的jni文件夹中运行“ ndk-build”命令。 To execute the Android.mk file run ndk-bild command within your root directory of project. 要执行Android.mk文件,请在项目的根目录中运行ndk-bild命令。

Your Android.mk should be look like this 您的Android.mk应该如下所示

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := cppTestProj
LOCAL_SRC_FILES := maintestapp.cpp \
                   Test_array_type.cpp

include $(BUILD_SHARED_LIBRARY)

Then run your ndk-build command 然后运行您的ndk-build命令

You can see this link for sample Android.mk file 您可以看到此链接以获取示例Android.mk文件

Update: 更新:

static {
        System.loadLibrary("hello-jni");
    }

for more information please refer HelloJni.java file of sample project. 有关更多信息,请参考示例项目的HelloJni.java文件。

Thanks 谢谢

您需要添加LOCAL_C_INCLUDES并包含可视C ++包含文件夹,因为您正在使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM