如何解决 C++ 中的链接器错误编译器
我必须在 CPP
编译器中编译 PJSIP
。因为我正在将 API 与 PJSIP 集成。它位于CPP
中。所以我必须使用g++
而不是gcc
。但现在我没有集成任何其他API。
但我在 CPP 编译器中遇到链接器错误。如果是C
编译器,则工作正常。
错误:
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) ... ...
实际上我没有更改makefile
中的任何内容。
注意: 在srtp.c
文件中,已经包含了alloc.h
文件。我称赞它并编译它。我只得到相同的链接器错误。我从两个方面思考。但我对此不确定。
1. 它没有与 .o
文件链接
2.它不带头文件。 (我对此不太清楚。)
请帮我解决这个问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
extern "C"
块中声明所有 C 符号;将您的#include
指令包装在这样的块中,或者将其放入标头本身中。 (检查标题中是否已经没有这样的块。)另请参阅 如何混合使用 C 和 C++。
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.
当
C
符号在C++
程序中变为未定义时,意味着它们的声明未标记为extern "C"
。处理它的标准方法是用以下内容包装
C
标头:When
C
symbols become undefined in aC++
program it means that their declarations are not marked asextern "C"
.The standard way to handle it is to wrap
C
headers with:这是您的 pjsip 项目中的链接器错误。您使用 xcode 还是其他 IDE 来开发这个项目?
这个错误是因为,上述文件没有成功链接到您的项目。
将下面缺少的库文件添加到您的项目中。
=>>libsrtp-arm-apple-darwin9.a
按照以下链接将您的库文件链接到您的项目中。
来源:https://www.chilkatsoft.com/xcode-link-static- lib.asp
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