当前位置: 代码迷 >> 综合 >> 在Mac OS X 10.9 上使用 NDK r9c 编译 FFTW 3.3.3
  详细解决方案

在Mac OS X 10.9 上使用 NDK r9c 编译 FFTW 3.3.3

热度:34   发布时间:2023-12-15 07:21:22.0

Mac OS X 10.9 Android NDK r9c 编译 FFTW 3.3.3

在Mac OS X 10.9 上使用 NDK  r9c 编译 FFTW 3.3.3

1.下载FFTW源代码

2.建立一个Android 工程,并且添加 NDK 支持

3.解压缩FFTW的源代码到刚刚建立的Android 目录下面 文件夹名字为 fftw-3.3.3

4.建立编译脚本 build.sh 并在命令行下执行

#!/bin/sh
# build.sh
# Compiles fftw3 for Android
# Make sure you have NDK_ROOT defined in .bashrc or .bash_profile


INSTALL_DIR="`pwd`/jni/fftw3"
SRC_DIR="`pwd`/fftw-3.3.3"


cd $SRC_DIR


export
PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-8/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"


mkdir -p $INSTALL_DIR
./configure --host=arm-eabi  --prefix=$INSTALL_DIR LIBS="-lc -lgcc" --enable-float


make
make install


exit 0




  • INSTALL_DIR tells make to install the compiled library in our project’s jni directory
  • PATH tells make to look for our tool chain in the NDK directory. Note that you might have to change this value – explore your NDK directory to make sure that the path exists
  • SYS_ROOT tells make where to look for system libraries and header files
  • ./configure --host=arm-eabi  tells make that we are cross-compiling a ARM architecture.

5.修改Android.mk 文件

# jni/Android.mk
LOCAL_PATH := $(call my-dir)


include $(CLEAR_VARS)


LOCAL_MODULE := fftw3


LOCAL_SRC_FILES := fftw3/lib/libfftw3.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/fftw3/include


include $(PREBUILT_STATIC_LIBRARY)