在android ndk中编译fftw3 [英] compiling fftw3 in android ndk

查看:46
本文介绍了在android ndk中编译fftw3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 android-ndk 的新手,到目前为止,我使用了 android-ndk 中的所有示例应用程序,现在我正在尝试在 android 中移植 fftw3 库,您能否建议我为此提供任何教程.

hi i am new to android-ndk so far i worked with all sample applications in android-ndk,now i am trying to port fftw3 library in android, can you plz suggest me any tutorial for this.

谢谢.

推荐答案

FFTW3构建系统使用了Autotools,所以不能直接和Android NDK一起使用.处理此问题的一篇很好的博客文章是 这里.

The FFTW3 build system makes use of Autotools, so that you can not use it directly with the Android NDK. A good blog post dealing with this issue is here.

这个想法是离线生成一个适当的 config.h 文件并创建 Android Makefiles,它替换通常由 Autotools 生成的缺失文件.

The idea is to generate a proper config.h file offline and to create Android Makefiles, which replace the missing ones normally generated by the Autotools.

要为您可能使用的不同本机模块实现模块化布局,我建议如下:

To achieve a modular layout for the different native modules you might use, I'd recommend the following:

在您的顶部 jni/ 目录中放置这两个文件:

In your top jni/ directory put these two files:

Application.mk:

    APP_OPTIM        := release
    APP_ABI          := armeabi armeabi-v7a
    APP_MODULES      := fftw3

Android.mk:

    TOP_DIR := $(call my-dir)
    include $(TOP_DIR)/fftw3/project/jni/Android.mk

这样,您可以通过创建 jni/new_module_name 目录然后将 new_module_name 添加到 APP_MODULES 列表来轻松添加新模块.

This way you can easily add a new module by creating a jni/new_module_name directory and then adding new_module_name to the APP_MODULES list.

然后新建一个jni/fftw3目录,放另一个Application.mk:

Then create a new jni/fftw3 directory and put another Application.mk there:

Application.mk:

    APP_PROJECT_PATH := $(call my-dir)/project
    APP_MODULES      += fftw3
    APP_OPTIM        := release
    APP_ABI          := armeabi armeabi-v7a

然后把原来的FFTW3包放到jni/fftw3/project/jni下.

Then put the original FFTW3 package under jni/fftw3/project/jni.

此时需要生成一个config.h.您可以使用像 this 之类的小型 shell 脚本来执行此操作.

At this point you need to generate a config.h. You can do this by using a small shell script like this.

最后一步是创建所需的 Android Makefile.在 jni/fftw3/project/jni 中放一个顶部 Android.mk:

The last step is to create the needed Android Makefile. In jni/fftw3/project/jni put a top Android.mk:

    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)

    include $(LOCAL_PATH)/api/sources.mk
    include $(LOCAL_PATH)/dft/sources.mk
    include $(LOCAL_PATH)/dft/scalar/sources.mk
    include $(LOCAL_PATH)/dft/scalar/codelets/sources.mk
    include $(LOCAL_PATH)/kernel/sources.mk
    include $(LOCAL_PATH)/rdft/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2cb/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2cf/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2r/sources.mk
    include $(LOCAL_PATH)/reodft/sources.mk

    LOCAL_MODULE := fftw3
    LOCAL_C_INCLUDES := $(LOCAL_PATH) 
        $(LOCAL_PATH)/api 
        $(LOCAL_PATH)/dft 
        $(LOCAL_PATH)/dft/scalar 
        $(LOCAL_PATH)/dft/scalar/codelets 
        $(LOCAL_PATH)/kernel 
        $(LOCAL_PATH)/rdft 
        $(LOCAL_PATH)/rdft/scalar 
        $(LOCAL_PATH)/rdft/scalar/r2cb 
        $(LOCAL_PATH)/rdft/scalar/r2cf 
        $(LOCAL_PATH)/rdft/scalar/r2r 
        $(LOCAL_PATH)/reodft

    # Use APP_OPTIM in Application.mk
    LOCAL_CFLAGS := -g

    include $(BUILD_SHARED_LIBRARY)

现在你必须创建所有这些 sources.mk 文件.例如.一个典型的 sources.mk 看起来像这样:

Frow now on you have to create all these sources.mk files. E.g. a typical sources.mk looks like this:

rdft/sources.mk:

    sources = buffered2.c 
              buffered.c 
              <....>
              vrank-geq1.c 
              vrank-geq1-rdft2.c

    LOCAL_SRC_FILES += $(sources:%=rdft/%)

调用应用顶层目录中的 ndk-build 脚本,你应该会得到两个现成的 FFTW3 库:

Call the ndk-build script in the top directory of your app and you should end up with two ready-to-use FFTW3 libraries:

  • libs/armeabi-v7a/libfftw3.so
  • libs/armeabi/libfftw3.so

这篇关于在android ndk中编译fftw3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆