构建 pjSip 2.5 - 无法对 'pj_jni_jvm' 进行未定义引用

Building pjSip 2.5 - unable to undefined reference to 'pj_jni_jvm'

正在尝试使用以下指南从 Android 的源构建 pjSIP - https://trac.pjsip.org/repos/wiki/Getting-Started/Android

  1. 检查 pjsip (2.5) 的来源
  2. 出口ANDROID_NDK_ROOT=/home/dev/android/android-ndk-r9b
  3. 出口TARGET_ABI=armeabi
  4. 出口[=52​​=]=android-13
  5. ./configure-android --use-ndk-cflags --disable-video --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-ssl --disable-ilbc-codec --disable-tls

  6. 配置成功。

  7. 清除 && 清理 && 生成

我得到以下错误 - >

../src/pj/guid_android.c:43: error: undefined reference to 'pj_jni_jvm'
../src/pj/guid_android.c:117: error: undefined reference to 'pj_jni_jvm'

导致此错误的链接调用的命令

/home/dev/android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -o ../bin/pjlib-test-arm-unknown-linux-androideabi \
             output/pjlib-test-arm-unknown-linux-androideabi/main.o  output/pjlib-test-arm-unknown-linux-androideabi/activesock.o  output/pjlib-test-arm-unknown-linux-androideabi/atomic.o  output/pjlib-test-arm-unknown-linux-androideabi/echo_clt.o  output/pjlib-test-arm-unknown-linux-androideabi/errno.o  output/pjlib-test-arm-unknown-linux-androideabi/exception.o  output/pjlib-test-arm-unknown-linux-androideabi/fifobuf.o  output/pjlib-test-arm-unknown-linux-androideabi/file.o  output/pjlib-test-arm-unknown-linux-androideabi/hash_test.o  output/pjlib-test-arm-unknown-linux-androideabi/ioq_perf.o  output/pjlib-test-arm-unknown-linux-androideabi/ioq_udp.o  output/pjlib-test-arm-unknown-linux-androideabi/ioq_unreg.o  output/pjlib-test-arm-unknown-linux-androideabi/ioq_tcp.o  output/pjlib-test-arm-unknown-linux-androideabi/list.o  output/pjlib-test-arm-unknown-linux-androideabi/mutex.o  output/pjlib-test-arm-unknown-linux-androideabi/os.o  output/pjlib-test-arm-unknown-linux-androideabi/pool.o  output/pjlib-test-arm-unknown-linux-androideabi/pool_perf.o  output/pjlib-test-arm-unknown-linux-androideabi/rand.o  output/pjlib-test-arm-unknown-linux-androideabi/rbtree.o  output/pjlib-test-arm-unknown-linux-androideabi/select.o  output/pjlib-test-arm-unknown-linux-androideabi/sleep.o  output/pjlib-test-arm-unknown-linux-androideabi/sock.o  output/pjlib-test-arm-unknown-linux-androideabi/sock_perf.o  output/pjlib-test-arm-unknown-linux-androideabi/ssl_sock.o  output/pjlib-test-arm-unknown-linux-androideabi/string.o  output/pjlib-test-arm-unknown-linux-androideabi/test.o  output/pjlib-test-arm-unknown-linux-androideabi/thread.o  output/pjlib-test-arm-unknown-linux-androideabi/timer.o  output/pjlib-test-arm-unknown-linux-androideabi/timestamp.o  output/pjlib-test-arm-unknown-linux-androideabi/udp_echo_srv_sync.o  output/pjlib-test-arm-unknown-linux-androideabi/udp_echo_srv_ioqueue.o  output/pjlib-test-arm-unknown-linux-androideabi/util.o -lpj-arm-unknown-linux-androideabi  -nostdlib -L/home/dev/android/android-ndk-r9b/platforms/android-13/arch-arm/usr/lib -L/home/dev/android/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/ -lm /home/dev/android/android-ndk-r9b/platforms/android-13/arch-arm/usr/lib/crtbegin_so.o -lgnustl_static  -lc -lgcc -ldl -lOpenSLES -llog   -L/home/dev/android/pjproject-2.5/pjlib/lib -L/home/dev/android/pjproject-2.5/pjlib-util/lib -L/home/dev/android/pjproject-2.5/pjnath/lib -L/home/dev/android/pjproject-2.5/pjmedia/lib -L/home/dev/android/pjproject-2.5/pjsip/lib -L/home/dev/android/pjproject-2.5/third_party/lib           -nostdlib -L/home/dev/android/android-ndk-r9b/platforms/android-13/arch-arm/usr/lib -L/home/dev/android/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/

代码 guid_androind.c

#include <pj/guid.h>
#include <pj/log.h>
#include <pj/string.h>

#include <jni.h>

extern JavaVM *pj_jni_jvm;

static pj_bool_t attach_jvm(JNIEnv **jni_env)
{
    if ((*pj_jni_jvm)->GetEnv(pj_jni_jvm, (void **)jni_env,
                               JNI_VERSION_1_4) < 0)
    {
        if ((*pj_jni_jvm)->AttachCurrentThread(pj_jni_jvm, jni_env, NULL) < 0)
        {
            jni_env = NULL;
            return PJ_FALSE;
        }
        return PJ_TRUE;
    }

    return PJ_FALSE;
}

#define detach_jvm(attached) \
    if (attached) \
        (*pj_jni_jvm)->DetachCurrentThread(pj_jni_jvm);

整天都在为这个错误而苦苦挣扎,非常感谢任何线索。同时我能够构建版本 2.3 而没有任何错误,但不是 2.5

我相信你错过了一步。 https://trac.pjsip.org/repos/wiki/Getting-Started/Android#BuildPreparation

将您的 config_site.h 设置为以下内容:

/* Activate Android specific settings in the 'config_site_sample.h' */
#define PJ_CONFIG_ANDROID 1
#include <pj/config_site_sample.h>