Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

compiling fftw3 in android ndk

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.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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:

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

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.

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

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

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

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)

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/%)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...