sonic icon indicating copy to clipboard operation
sonic copied to clipboard

How am I supposed to compile and use the library instead of the sonic program?

Open mavavilj opened this issue 2 years ago • 5 comments

How am I supposed to compile and use the library instead of the sonic program?

I'm interested in computing a spectrogram.

I download, unzip, and then do:

make

After this I do:

gcc main.c -L. -lsonic

which fails to:


/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccIksmQF.o: in function `runSonic':
main.c:(.text+0x77): undefined reference to `openInputWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0xe7): undefined reference to `openOutputWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0xfe): undefined reference to `closeWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0x1e7): undefined reference to `readFromWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0x271): undefined reference to `writeToWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0x299): undefined reference to `closeWaveFile'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: main.c:(.text+0x2ae): undefined reference to `closeWaveFile'
collect2: error: ld returned 1 exit status

mavavilj avatar May 03 '22 12:05 mavavilj

Okay fixed by doing:

LD_LIBRARY_PATH=./ export L_LIBRARY_PATH

gcc main.c wave.c -L. -lsonic

mavavilj avatar May 03 '22 12:05 mavavilj

But now I got stuck in trying to compile this with spectrogram.c and kiss_fft.

I found no instructions for this.

mavavilj avatar May 03 '22 13:05 mavavilj

Particularly, do I need to edit:

https://github.com/waywardgeek/sonic/blob/master/Makefile#L65

or is it enough to resolve https://github.com/waywardgeek/sonic/blob/master/spectrogram.c#L9 ?

mavavilj avatar May 07 '22 15:05 mavavilj

You don’t say what platform you are trying to use.

The simplest way on a Unix-like system is to make the libsonic library make libsonic2.a

And then when you compile your library include libsonic2.a in your command line. That will get you the spectrogram, along with some things you don’t need.

You can always edit out the stuff you don’t need in the libsonic2 library, if you wish.

— Malcolm

MalcolmSlaney avatar May 07 '22 17:05 MalcolmSlaney

Well first Linux (OpenSuse), but afterwards I was interested in seeing, if this can be made work on Android via JNI and NDK.

But you didn't clarify, how do I enable kissfft.

mavavilj avatar May 07 '22 17:05 mavavilj