0

I have followed the build instructions defined in the android example app (AppRTCDemo) README (https://chromium.googlesource.com/external/webrtc/+/master/talk/examples/android/README), including setting the build flag "build_with_libjingle=1". When I run either "ninja -C out_android/Debug AppRTCDemo" (or the Release version), it compiles everything associated with libjingle. However, when it compiles libjingle_peerconnection_so.so, it seems to forget to include various libjingle static libraries. I can tell this, because when I include the libjingle_peerconnection_so.so file in my own project (that uses things like buzz::QN_MESSAGE and XmlElement objects) the build complains that those (and other things) are not defined. BUT every WebRTC object I have in my code IS defined, and the compiler does not complain.

I have also used nm -C and grep on the libjingle_peerconnection_so.so file, looking for the symbols, and there are NO results returned. However, the libjingle_peerconnection_so.ninja file clearly has the necessary libraries included (librtc_xmpp, etc.).

For my project, I am using the ndk-build system with .mk files (I am still using the ninja build stuff for libjingle / WebRTC). I have tried ditching the .so file, and instead using EVERY static library in my .mk file, but that then introduces a bunch of other not defined errors that make less sense than using the .so file. I have multiple versions of the .mk file, I have included the one using the libjingle_peerconnection_so.so file below.

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libjingle_peerconnection_so
cmd-strip :=
LOCAL_SRC_FILES := libjingle_peerconnection_so.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := myproject
LOCAL_MODULE_TAGS := optional
LOCAL_CPP_EXTENSION := .cpp \
    .cc

LOCAL_SRC_FILES := \
    presencepushtask.cc \
    CallItem.cpp \
    Video.cpp \
    XMPP.cpp \
    JNIMain.cpp

LIBJINGLE_CPPFLAGS := \
    -DHAMMER_TIME=1 \
    -DHAS_OPENSSL_1_0 \
    -DHAVE_DTLS_SRTP \
    -DGTEST_RELATIVE_PATH \
    -DDISABLE_DYNAMIC_CAST \
    -D_REENTRANT \
    -DWEBRTC_POSIX \
    -DOS_LINUX=OS_LINUX \
    -DLINUX \
    -DANDROID \
    -DEXPAT_RELATIVE_PATH \
    -DSRTP_RELATIVE_PATH \
    -DXML_STATIC \
    -DFEATURE_ENABLE_SSL \
    -DHAVE_OPENSSL_SSL_H=1 \
    -DFEATURE_ENABLE_VOICEMAIL \
    -DFEATURE_ENABLE_PSTN \
    -DHAVE_WEBRTC_VIDEO \
    -DHAVE_WEBRTC_VOICE \
    -DHAVE_SRTP \
    -DLOGGING \
    -DNO_SOUND_SYSTEM \
    -DARCH_CPU_LITTLE_ENDIAN \
    -DJSONCPP_RELATIVE_PATH \
    -DWEBRTC_RELATIVE_PATH \
    -D_DEBUG

LOCAL_CFLAGS := \
    $(LIBJINGLE_CPPFLAGS) \
    -O2 \
    -std=c++11 \
    -fexceptions

LOCAL_C_INCLUDES := \
    $(LOCAL_PATH) \
    $(LOCAL_PATH)/../../ProjectLibs \
    $(LOCAL_PATH)/../../ProjectLibs/Kino \
    $(LOCAL_PATH)/../../ProjectLibs/android-logging \
    $(LOCAL_PATH)/../../ThirdPartyLibs/openssl/openssl/include \
    $(LOCAL_PATH)/../../ThirdPartyLibs/WebRTC/src \
    $(LOCAL_PATH)/../../ThirdPartyLibs/WebRTC/src/webrtc \
    $(LOCAL_PATH)/../../ThirdPartyLibs/WebRTC/src/chromium/src/third_party/jsoncpp/source/include \
    $(LOCAL_PATH)/../../ThirdPartyLibs/WebRTC/src/chromium/src/third_party/icu/source/common

LOCAL_SHARED_LIBRARIES := \
    libcrypto-mod \
    libssl-mod \
    libjingle_peerconnection_so

LOCAL_LDLIBS := \
    -L$(NDK_PROJECT_PATH)/toolchain/sysroot/usr/lib \
    -llog \
    -lOpenSLES \
    -lGLESv2 \
    -lc \
    -ljnigraphics \
    -ldl

include $(BUILD_SHARED_LIBRARY)

What the heck am I doing wrong? Or is there something wrong with the build system?

UPDATE 1: Of course, when you visit something the next day, everything changes. Now when I run nm on the libjingle_peerconnection_so.so file, it shows that the functions / symbols are there. However, my build setup still claims that they are not defined, even though they clearly are.

UPDATE 2: I have suppressed the undefined errors with LOCAL_ALLOW_UNDEFINED_SYMBOLS := true in the .mk file, and that completes the build and created the android .so files in libs/armeabi-v7a/. When I nm those files, the symbols are found. However, when everything is loaded to the android device, the application crashes, saying that it cannot find (for example) the symbol _ZN4buzz11QN_PRESENCEE referenced in my library (myproject.so). The nm results:

nm libs/armeabi-v7a/libkinoproject.so | grep QN_PRESENCE
4983:         U _ZN4buzz10QN_PRESENCEE

nm libs/armeabi-v7a/libjingle_peerconnection_so.so | grep QN_PRESENCE
100840:005f65f8 d _ZN4buzz11QN_PRESENCEE
AeroBuffalo
  • 1,126
  • 1
  • 11
  • 31

2 Answers2

0

I still do not know what was going on. Ultimately, I decided to write my own ninja build files (using the one created by gyp / Google for the libjingle_peerconnection_so.so as a tempalte) and that "solved" the problem. I did not have to build all of the static library files. Instead, I was able to just reference them (as the libjingle_peerconnection_so.ninja file did) and all of the symbols and what now were properly found / defined. I guess, somehow, the old ndk-build / .mk build system and the new ninja build system just do NOT mix.

I am not going to mark this as the answer, in case someone in the future has a definitive / real answer.

AeroBuffalo
  • 1,126
  • 1
  • 11
  • 31
0

@AeroBuffalo this is not an answer but a barebones build-debug strategy for massive code bases such as webrtc/jingle/chromium.

Such errors pop up in the msvc world during compilation or linking stage on a fresh sync of webrtc. I turn on the verbose/diagnostic build output mode and then compare the command line compiler flags (mostly pre-compile flags ) across all the libraries.

Like you experienced, I end up with little logical or intuitive understanding in the end for quite a few resolutions. I am unfamiliar with linux/android build environment but analyzing verbose dump of the build logs might help.

I am very new to android development and began playing with getting a native screen sharing app via webrtc/libjingle going. Please share any other issues you encountered in your ninja/ndk build environments.

sith
  • 447
  • 7
  • 15