How to link libjingle_peerconnection_so.so to a project and call classes from it?

  android-ndk, android.mk, c++, webrtc

I try to build my jni class with a single line that tries to call webrtc audio processing.

webrtc::AudioProcessing* apm = webrtc::AudioProcessingBuilder().Create();

I also try to link the libjingle_peerconnection_so.so to my project so that I could use implementation of the audio processing from this common library. My Android.mk looks as follows:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libwebrtc
PATH_TO_WEBRTC := /home/artemy/dev/webrtc_src/src
LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../../libs/$(TARGET_ARCH_ABI)/libjingle_peerconnection_so.so
LOCAL_EXPORT_C_INCLUDES := $(PATH_TO_WEBRTC) $(PATH_TO_WEBRTC)/third_party/abseil-cpp
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := audio_processing_jni
LOCAL_SRC_FILES := audio_proc_jni.cpp
LOCAL_C_INCLUDES := audio_proc_jni.h 
LOCAL_LDLIBS := -llog
LOCAL_STATIC_LIBRARIES := libwebrtc

include $(BUILD_SHARED_LIBRARY)

However the project fails to link:

[armeabi-v7a] Compile++ thumb: audio_processing_jni <= audio_proc_jni.cpp
[armeabi-v7a] SharedLibrary  : libaudio_processing_jni.so
ap/audio_proc_jni.cpp:11: error: undefined reference to 'webrtc::AudioProcessingBuilder::AudioProcessingBuilder()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Is that possible or I need to find another way to webrtc directly from my native code?

Source: Windows Questions C++

LEAVE A COMMENT