简体   繁体   English

如何使用android-ndk?

[英]How to use android-ndk?

I use PTAM code taken from here . 我使用从此处获取的PTAM代码。 I try to make an android application with this code. 我尝试使用此代码制作一个android应用程序。

The PTAM code uses libcvd, TooN, gvars3 library. PTAM代码使用libcvd,TooN,gvars3库。 I generate a .so file from my c++ test file using ndk-build . 我使用ndk-build从我的c ++测试文件生成一个.so文件。

Firstly, I try to run below code on android phone : 首先,我尝试在Android手机上运行以下代码:

#include <string.h>
#include <jni.h>

extern "C" {

    int returnInt()
    {

        int returnVal = 4;
        return returnVal;
    }
}

It can generate .so file without any errors. 它可以生成.so文件,没有任何错误。 If I add #include < TooN/TooN.h > , `ndk-build says that 如果我添加#include < TooN/TooN.h > ,`ndk-build表示

fatal error: TooN/TooN.h: No such file or directory
 #include <TooN/TooN.h>
                       ^
compilation terminated.

Android.mk is : Android.mk是:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := test-jni
LOCAL_SRC_FILES := test-jni.cpp

include $(BUILD_SHARED_LIBRARY)

How can I solve this error message? 我该如何解决此错误消息?

fatal error: TooN/TooN.h: No such file or directory #include <TooN/TooN.h> 致命错误:TooN / TooN.h:没有这样的文件或目录#include <TooN / TooN.h>

When you use <> with #include , the compiler will search for the file in your include path (and possibly other predefined directories). 当将<>#include ,编译器将在您的include路径(可能还有其他预定义目录)中搜索文件。

To add a directory to your include path when building a module in Android.mk you would add it to LOCAL__INCLUDES . 要在Android.mk构建模块时将目录添加到包含路径,请将其添加到LOCAL__INCLUDES For example, if the full path to TooN.h is /home/foobar/TooN/TooN.h you should do this: 例如,如果TooN.h的完整路径为/home/foobar/TooN/TooN.h ,则应执行以下操作:

LOCAL_C_INCLUDES += /home/foobar

I get fatal error: iostream: No such file or directory.There is no folder named iostream under usr/include or usr/local/include. 我收到致命错误:iostream:没有这样的文件或目录。在usr / include或usr / local / include下没有名为iostream的文件夹。

The iostream class is part of the STL, so you need to specify an STL implementation to build against. iostream类是STL的一部分,因此您需要指定要构建的STL实现。 This can be done using the APP_STL variable in Application.mk . 可以使用Application.mkAPP_STL变量来完成此操作。 For example: 例如:

APP_STL := gnustl_shared

See this page for a list of STL implementations available with the NDK. 请参见本页面可用与NDK STL实现的列表。

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

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