1

I'm trying to build Android app for SIP-connections using PJSIP library with OpenSSL support. First I've built PJSIP with OpenSSL, next 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. If I don't use OpenSSL, everything builds fine.

I'm not a specialist in C/C++, so cannot understand how to solve the problem. Please help.

Building on MacOS, PJSIP version: 2.14.1, NDK 22.1.7171670 and OpenSSL 3.3.1.

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

1 Answer 1

2

What's happening here is duplicate symbols are defined in both the PJSIP SRTP library and Open SSL's default implementation. Specifically PJSIPs SRTP has it's own implementation of a symbol aes_icm.c that's already implemented by OpenSSL as aes_icm_ossl.c.

A (hopefully) quick and easy fix is to exclude the SRTP version. You can do this by locating the build configuration file PJSIPs SRTP is managed through (usually called config_site.h and might be at this path pjproject/pjlib/include/pj/config_site.h) and add these 3 lines:

#define PJMEDIA_HAS_SRTP 1
#define SRTP_AES_ICM 0
#define SRTP_AES_ICM_OSSL 1

This should disable the SRTP implementation of AES and enable the use of OpenSSL's version. Once you've modified the file just rebuild the project and you should be good. Hope that helps, let me know if you encounter more issues with it.

5
  • Understood the situation, thanks for the explanation. Regarding these constants — I couldn't find the last two anywhere in the PJSIP and SRTP source code. So even if I define them, they won't be checked anywhere. A Google search for SRTP_AES_ICM_OSSL also yielded no results. SRTP_AES_ICM can be found, but in a different context (as an early analogue to SRTP_AES_128_ICM). Commented Jul 7 at 19:11
  • Odd, they appear to be defined as such in the error. I'll do some digging and get back to you.
    – Anon520
    Commented Jul 8 at 0:29
  • @ЗмейГорыныч Unfortunately I haven't been able to find anywhere else they would be located, if you could give your files another check through to see if you can find them that would be great.
    – Anon520
    Commented Jul 8 at 11:40
  • They're definitely not in there. Maybe a good option is to build OpenSSL without SRTP, if SRTP is already included in PJSIP? Commented Jul 8 at 11:59
  • Yeah that could work
    – Anon520
    Commented Jul 8 at 23:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.