Question

I have to compile PJSIP in CPP compiler. Because I am integrating an API with PJSIP. It is in CPP. So I have to use g++ instead of gcc. But now I didn't integrate any other API.

But I am getting linker error in CPP compiler. If it is C compiler, it is working fine.

Error:

Undefined symbols for architecture arm:
  "_crypto_alloc", referenced from:
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**)in libsrtp-arm-apple-darwin9.a(srtp.o)
      srtp_stream_alloc(srtp_stream_ctx_t**, srtp_policy_t const*) in libsrtp-arm-apple-darwin9.a(srtp.o)
      _srtp_create in libsrtp-arm-apple-darwin9.a(srtp.o)
  "_aes_icm_context_init", referenced from:
      srtp_kdf_init(srtp_kdf_t*, unsigned char const*)in libsrtp-arm-apple-darwin9.a(srtp.o)
  "_crypto_kernel_load_debug_module", referenced from:
      _srtp_init in libsrtp-arm-apple-darwin9.a(srtp.o)
  "_rdbx_init", referenced from:
      srtp_stream_init(srtp_stream_ctx_t*, srtp_policy_t const*) in libsrtp-arm-apple-darwin9.a(srtp.o)
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**)in libsrtp-arm-apple-darwin9.a(srtp.o)
  "_key_limit_clone", referenced from:
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**)in libsrtp-arm-apple-darwin9.a(srtp.o)
  "_auth_get_tag_length", referenced from:
      _srtp_unprotect_rtcp in libsrtp-arm-apple-darwin9.a(srtp.o)
      _srtp_protect_rtcp in libsrtp-arm-apple-darwin9.a(srtp.o)
      _srtp_unprotect in libsrtp-arm-apple-darwin9.a(srtp.o)
      _srtp_protect in libsrtp-arm-apple-darwin9.a(srtp.o)
...
...

Actually I didn't change anything in makefile.

NOTE: In srtp.c file, already included alloc.h file. I commended it and compiled it. I got the same linker error only. I am thinking in two ways. But I am not sure with this.
1. It is not linking with .o files
2. It is not taking the header files. (I am not clear with this.)

Please help me to resolve this issue.

Was it helpful?

Solution

  1. Don't compile C source code with a C++ compiler. Just compile it with a C compiler and link it into your C++ program using a C++ linker.
  2. Declare all C symbols in an extern "C" block; either wrap your #include directives in such a block, or put it in the headers themselves. (Check whether there's not such a block in the headers already.)

See also How to mix C and C++ in the C++ FAQ.

OTHER TIPS

When C symbols become undefined in a C++ program it means that their declarations are not marked as extern "C".

The standard way to handle it is to wrap C headers with:

#ifdef __cplusplus
extern "C" {
#endif

// C declarations here

#ifdef __cplusplus
}
#endif

It's linker error in your pjsip project. Are you using xcode or anyother IDE to develop this project?

This error is because, the above files are not linked to your project successfully.

Add this below missing library file into your project.

=>>libsrtp-arm-apple-darwin9.a

Follow the below link to link your library file into your project.

SOURCE: https://www.chilkatsoft.com/xcode-link-static-lib.asp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top