FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.66k stars 651 forks source link

Link FFTW in Android Studio #340

Closed fjrdev closed 8 months ago

fjrdev commented 8 months ago

I want to link the fftw3 library, which I built from source, to my native Android Studio application. Therefore I included the headers and added libfftw3.a (Mach-O 64-bit object arm64) to my jniLibs/arm64-v8a/ folder. I link the library with CMake:

set(VENDOR_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/arm64-v8a)

add_library(fftw STATIC IMPORTED)
set_target_properties( fftw PROPERTIES IMPORTED_LOCATION ${VENDOR_LIB_DIR}/libfftw3.a )
target_link_libraries( exec fftw )

In my build.gradle I added the following C++ flags:

defaultConfig {
    applicationId "com.example.demo"
    minSdk 33
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    externalNativeBuild {
        cmake {
            arguments "-DCMAKE_TOOLCHAIN_FILE=/Users/username/Library/Android/sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake",
                      "-DANDROID_PLATFORM=33",
                      "-DAPP_PLATFORM=33",
                      "-DANDROID_ABI=arm64-v8a"
            cppFlags "-L/Users/username/AndroidStudioProjects/demo/app/src/main/cpp/fftw-3.3.10/.libs/ -lfftw3 -lm "
        }
    }
    ndk {
        abiFilters 'arm64-v8a'

    }
}

However, after including the library in my exec with #include "fftw-3.3.10/api/fftw3.h", I get the following error as soon as I want to call a related function ld: error: undefined symbol: fftw_malloc. Im aware that the application is not correctly linked to the library, but I don't know what's wrong with it, since I could successfully link other third party libraries this way.