kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.65k stars 253 forks source link

How to build in Android? #115

Closed fisher111777 closed 7 months ago

beezow commented 3 years ago

Follow the android documentation to build a native library, be sure to choose a CMake based build as it will be easier to include (i think). You will have to setup your own C linkage if you want to call KFR functions directly from Java. I'd suggest doing the bulk of the work in C/C++. Clone the KFR repository into the src/main/cpp directory. Within the src/main/cpp/CmakeLists.txt add in

## Include KFR subdirectory
add_subdirectory(kfr)
## replace native-lib with your library name.
target_link_libraries(native-lib kfr)

This will include the KFR project to get built with your app. You may come across some errors building. I had to disable some features within the KFR CmakLists.txt file. Specifically i removed everything related to kfr_io Here is a link to my modified repo. It probably isn't the best way to do this but it gets a working KFR build for android.

I am no good at CMake, but i suspect there is a way to detect it is being cross complied for android and disable these features. Or maybe they can be modified to work. Someone that is better at CMake and more familiar with the KFR please feel free to advise on doing this properly. Would be nice to get a proper solution documented. Let me know if you have any questions.