An error occurs that the defined function is not defined during the Android ndk build.

Asked 2 years ago, Updated 2 years ago, 98 views

Please help me to get an error in the "process(input, output)" of the code below during the ndk-build operation.

[audacity_process.cpp]

#include <jni.h>
#include <string.h>
#include "noisereduction/Audacity.h"
#include <stdio.h>

#include <android/log.h>

JNIEXPORT void JNICALL Java_com_example_gonghoonnt_audacity_Audacity_preprocess(JNIEnv* env, jobject, jstring inputPath, jstring outputPath)
{
    const char * input = (env)->GetStringUTFChars(inputPath, 0);
    const char * output = (env)->GetStringUTFChars(outputPath, 0);

    process(input, output); // Error occurred

    return;
}

[ERROR]

jni/audacity_process.cpp:13: error: undefined reference to 'process(char const*, char const*)'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi-v7a/libnoisereduction.so] Error 1

[Audacity.h]

void process (const char* inputPath; const char* outputPath);

[Audacity.cpp]

#include <iostream>
#include "NoiseReduction.h"
#include <sndfile.h>
#include "loguru.hpp"
#include "Utils.h"
#include "cxxopts.hpp"
#include "Audacity.h"

void process(const char* inputPath, const char* outputPath) {
    auto ctx = openAudioFile(inputPath);

    NoiseReduction::Settings settings;
    NoiseReduction reduction(settings, ctx);
    auto t0 = 0;
    auto t1 = ctx.info.frames;

    reduction.ProfileNoise(t0, t1);
    reduction.ReduceNoise(outputPath);

    return 0;
}

I made it as above, but I don't know what to do because there is an error that says it's not defined.

In addition, android.mk and application.mk are organized as follows:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := noisereduction

LOCAL_CFLAGS = -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_H

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

FILES := audacity_process.cpp

LOCAL_SRC_FILES := $(FILES)

LOCAL_LDLIBS :=  -llog

include $(BUILD_SHARED_LIBRARY)
APP_ABI:= armeabi-v7a arm64-v8ax86

Please give me your opinion on which parts to modify or add.

android ndk jni

2022-09-21 17:41

1 Answers

It's a self-answer.

Error occurred because Audacity file was not added to file Android.mk.


2022-09-21 17:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.