0

我必须在编译器PJSIPCPP编译。因为我正在将 API 与PJSIP. 它在CPP. 所以我必须使用g++而不是gcc. 但现在我没有集成任何其他 API。

但是我在CPP编译器中遇到链接器错误。如果它是C编译器,它工作正常。

错误:

架构臂的未定义符号:
  “_crypto_alloc”,引用自:
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**) 在 libsrtp-arm-apple-darwin9.a(srtp.o)
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 srtp_stream_alloc(srtp_stream_ctx_t**, srtp_policy_t const*)
      _srtp_create 在 libsrtp-arm-apple-darwin9.a(srtp.o)
  “_aes_icm_context_init”,引用自:
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 srtp_kdf_init(srtp_kdf_t*, unsigned char const*)
  “_crypto_kernel_load_debug_module”,引用自:
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 _srtp_init
  “_rdbx_init”,引用自:
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 srtp_stream_init(srtp_stream_ctx_t*, srtp_policy_t const*)
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**) 在 libsrtp-arm-apple-darwin9.a(srtp.o)
  “_key_limit_clone”,引用自:
      srtp_stream_clone(srtp_stream_ctx_t const*, unsigned int, srtp_stream_ctx_t**) 在 libsrtp-arm-apple-darwin9.a(srtp.o)
  “_auth_get_tag_length”,引用自:
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 _srtp_unprotect_rtcp
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 _srtp_protect_rtcp
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 _srtp_unprotect
      libsrtp-arm-apple-darwin9.a(srtp.o) 中的 _srtp_protect
...
...

其实我没有改变任何东西makefile

注意:srtp.c文件中,已包含alloc.h文件。我表扬了它并编译了它。我只得到了相同的链接器错误。我从两个方面考虑。但我不确定这一点。
1.不与.o文件链接
2.不带头文件。(我不清楚这一点。)

请帮我解决这个问题。

4

3 回答 3

2

C符号在程序中变得未定义时,C++这意味着它们的声明没有被标记为extern "C".

处理它的标准方法是C用以下方式包装标题:

#ifdef __cplusplus
extern "C" {
#endif

// C declarations here

#ifdef __cplusplus
}
#endif
于 2011-10-04T10:17:27.167 回答
2
  1. 不要使用 C++ 编译器编译 C 源代码。只需使用 C 编译器对其进行编译,然后使用 C++ 链接器将其链接到您的 C++ 程序中。
  2. extern "C"声明一个块中的所有 C 符号;要么将您的指令包装#include在这样的块中,要么将其放在标题本身中。(检查标题中是否已经没有这样的块。)

另请参阅C++ 常见问题解答中的如何混合 C 和 C++

于 2011-10-04T10:20:13.417 回答
0

这是您的 pjsip 项目中的链接器错误。您是否使用 xcode 或任何其他 IDE 来开发此项目?

这个错误是因为,上面的文件没有成功链接到你的项目。

将以下缺少的库文件添加到您的项目中。

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

按照下面的链接将您的库文件链接到您的项目中。

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

于 2016-12-03T02:07:56.113 回答