错误:未定义对'slCreateEngine'的引用

时间:2019-06-10 10:36:13

标签: java android android-ndk java-native-interface opensl

我想实现OpenSL ES以获得更好的音频性能。我正在尝试集成 openSL库,但我在下面提到了一些问题

error: undefined reference to 'slCreateEngine' error: undefined reference to 'SL_IID_ENGINE'

我从git参考下面获取了代码

https://github.com/googlesamples/android-ndk/tree/master/native-audio

我的Java代码

 /** Native methods, implemented in jni folder */
    public static native void createEngine();
    public static native void createBufferQueueAudioPlayer(int sampleRate, int samplesPerBuf);
    public static native boolean createAudioRecorder();
    public static native void startRecording();
    public static native void shutdown();
    public static native boolean selectClip(int which, int count);
    public static native void setPlayingAssetAudioPlayer(boolean isPlaying);
    public static native void setPlayingUriAudioPlayer(boolean isPlaying);



    // Used to load the 'native-lib' library on application startup.
    static {
        System.loadLibrary("native-lib");
    }

我将 CMakeLists.text 文件包含在 Gradle

 android {
        compileSdkVersion 28
        buildToolsVersion "29.0.0"
        defaultConfig {
            applicationId "com.example.myapplication"
            minSdkVersion 25
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        externalNativeBuild {
            cmake {
                version "3.10.2"
                path "src/main/cpp/CMakeLists.txt"
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        }
  

错误

D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:185: error: undefined reference to 'slCreateEngine'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_ENGINE'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_ENVIRONMENTALREVERB'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_ENVIRONMENTALREVERB'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:228: error: undefined reference to 'SL_IID_ANDROIDSIMPLEBUFFERQUEUE'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_RECORD'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_ANDROIDSIMPLEBUFFERQUEUE'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_EFFECTSEND'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_VOLUME'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_BUFFERQUEUE'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_PLAY'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_BUFFERQUEUE'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_EFFECTSEND'
D:/android-ndk-abc/MyApp/app/src/main/cpp/native-lib.cpp:0: error: undefined reference to 'SL_IID_VOLUME'

注意: 我发现了相同的问题undefined reference to slCreateEngine,但没有任何帮助的答案。

谢谢。

0 个答案:

没有答案