fftw3 android 编译,compiling fftw3 in 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.

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值