Search code examples
androidcmakefilejava-native-interfacekissfft

Using native C Kiss_fft.c to calculate fft in android


My goal is to compile the kiss_fft libraries to use in JNI for android development. However to begin with, I am attempting to just use the kiss_fft libraries on my linux machine in C.

when using Kiss_fft.c or Kiss_fftr.c from Kiss_fft (Kissfft )to calculate the DFT. How exactly do you compile their libraries into your own file. In the top of my source C file, I #include kiss_fft.h and #include kiss_fftr.h, and also either place the kiss_fft souce code in my project root directory or in /usr/include/ in linux, then I compile with a makefile similar to this one:

#Makefile

#ARGS = -g -ansi -pedantic -Wall -Werror -O1
ARGS = -g -lsndfile -O1 -lm


FILES = spec_subv4.o kiss_fftr.o kiss_fft.o

spec_sub: $(FILES)
gcc $(ARGS) $(FILES) -o spec_sub  

spec_subv4.o:   spec_subv4.c 
gcc -lsndfile $(ARGS) -c spec_subv4.c -o spec_subv4

kiss_fftr.o:    kiss_fftr.c kiss_fftr.h kiss_fftr.h _kiss_fft_guts.h
gcc $(ARGS) -c kiss_fftr.c -o kiss_fftr

kiss_fft.o: kiss_fft.c _kiss_fft_guts.h
gcc $(ARGS) -c kiss_fftr.c -o kiss_fft

Looking through all the kiss_fft source files, I wrote this make file to build all the dependencies. However I still get

undefined reference to kiss_fft

undefined reference to kiss_fft_alloc

Which are internal functions of the kiss_fft libs.

Any help would be appreciated. Thanks


Solution

  • Worked it out, thanks for the input. I simply just compiled with:

    gcc $@ -g -lsndfile -lm -std=gnu99 spec_sub_kiss.c kiss_fft.c kiss_fftr.c -o spec_sub_kiss
    

    Where the -lsndfile is the libraries to read and write some .wav files for my project.