pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2.05k stars 780 forks source link

"Duplicate symbol" error when building Android SWIG bindings #4009

Closed coffeeplanter closed 4 months ago

coffeeplanter commented 4 months ago

Describe the bug

Trying to build demo Android app included in the repo. Built PJSIP with OpenSSL, trying to generate SWIG Java bindings and after entering command make getting three errors of duplicate symbol in aes_icm.c and aes_icm_ossl.c files. I'm not a specialist in C/C++, so cannot understand how to solve the problem. Please help.

Steps to reproduce

Built OpenSSL Built PJSIP Trying to build SWIG Java bindings (entered make)

PJSIP version

2.14.1

Context

Building on MacOS for Android app Using NDK 22.1.7171670 configure-android --with-ssl=[path] config_site.h — default values Using OpenSSL 3.3.1

Log, call stack, etc

ld: error: duplicate symbol: srtp_aes_icm_128
>>> defined at aes_icm.c
>>>            aes_icm.o:(srtp_aes_icm_128) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a
>>> defined at aes_icm_ossl.c
>>>            aes_icm_ossl.o:(.data.rel.ro.srtp_aes_icm_128+0x0) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a

ld: error: duplicate symbol: srtp_aes_icm_256
>>> defined at aes_icm.c
>>>            aes_icm.o:(srtp_aes_icm_256) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a
>>> defined at aes_icm_ossl.c
>>>            aes_icm_ossl.o:(.data.rel.ro.srtp_aes_icm_256+0x0) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a

ld: error: duplicate symbol: srtp_mod_aes_icm
>>> defined at aes_icm.c
>>>            aes_icm.o:(srtp_mod_aes_icm) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a
>>> defined at aes_icm_ossl.c
>>>            aes_icm_ossl.o:(.data.srtp_mod_aes_icm+0x0) in archive /pjproject/third_party/lib/libsrtp-aarch64-unknown-linux-android.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [android/pjsua2/src/main/jniLibs/arm64-v8a/libpjsua2.so] Error 1
make: *** [java] Error 2
sauwming commented 4 months ago

aes_icm and aes_icm_ossl are not supposed to be built together. https://github.com/pjsip/pjproject/blob/master/third_party/build/os-auto.mak.in#L54

Try cleaning and rebuilding. Follow the docs.

coffeeplanter commented 4 months ago

As far as I understand the problem is that SRTP is also included in OpenSSL, so duplicated symbols are defined in both the PJSIP SRTP library and OpenSSL default implementation. This is not described in docs unfortunatelly.