我在GitHub上找到了this,它是伟大的SoundTouch C ++库的包装器。
我对NDK来说是全新的,所以你们中有什么能向我解释如何正确设置它?
我从GitHub下载了zip并将目录复制到我现有的项目中。但是,它无法找到原生C ++函数。
我尝试使用ndk-build
编译库,但我遇到了两个错误。这是我的终端日志:
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.
Android NDK: WARNING:/home/daniele/AndroidStudioProjects/Chords2/app/jni/Android.mk:soundtouch: non-system libraries in linker flags: -lgcc
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:/home/daniele/AndroidStudioProjects/Chords2/app/jni/Android.mk:soundtouch: non-system libraries in linker flags: -lgcc
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi-v7a] Compile++ thumb: soundtouch <= soundtouch-jni.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= AAFilter.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= FIFOSampleBuffer.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= FIRFilter.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= cpu_detect_x86.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= RateTransposer.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= SoundTouch.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= TDStretch.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= BPMDetect.cpp
[armeabi-v7a] Compile++ thumb: soundtouch <= PeakFinder.cpp
[armeabi-v7a] SharedLibrary : libsoundtouch.so
[armeabi-v7a] Install : libsoundtouch.so => libs/armeabi-v7a/libsoundtouch.so
[armeabi] Compile++ thumb: soundtouch <= soundtouch-jni.cpp
/home/daniele/AndroidStudioProjects/Chords2/app/jni/soundtouch-jni.cpp:133:2: error:
no matching function for call to 'convertInput16'
convertInput16(ar, fBufferIn, BUFF_SIZE);
^~~~~~~~~~~~~~
/home/daniele/AndroidStudioProjects/Chords2/app/jni/soundtouch-jni.cpp:58:13: note:
candidate function not viable: no known conversion from
'soundtouch::SAMPLETYPE *' (aka 'short *') to 'float *' for 2nd argument
static void convertInput16(jbyte*, float*, int);
^
/home/daniele/AndroidStudioProjects/Chords2/app/jni/soundtouch-jni.cpp:210:16: error:
no matching function for call to 'write'
processed += write(fBufferIn, fBufferOut, nSamples * cha...
^~~~~
/home/daniele/AndroidStudioProjects/Chords2/app/jni/soundtouch-jni.cpp:56:12: note:
candidate function not viable: no known conversion from
'soundtouch::SAMPLETYPE *' (aka 'short *') to 'const float *' for 1st
argument
static int write(const float*, queue<signed char>*, int, int);
^
2 errors generated.
make: *** [/home/daniele/AndroidStudioProjects/Chords2/app/obj/local/armeabi/objs/soundtouch/soundtouch-jni.o] Error 1
答案 0 :(得分:1)
嗨,你必须编译库。
我建议你使用:
Linux ubuntu
NDK 14rb
首先使用以下命令更新Linux
sudo apt-get update
sudo apt-get upgrade
设置NDK环境变量:
export ANDROID_NDK=~/Desktop/ndk-folder
export NDK_ROOT=$ANDROID_NDK
export PATH=${PATH}:${ANDROID_NDK}
然后打开终端并转到项目文件夹中的jni文件夹
要编译库,只需输入以下命令:
ndk-build
答案 1 :(得分:1)
仅使用NDK 14。 NDK 15和16不足以用于NDK建筑。他们遇到了问题。 从https://developer.android.com/ndk/downloads/older_releases.html和项目设置更改到NDK 14的提取位置。它将解决与NDK相关的问题。