如何解决C++编译器中的链接器错误
How to resolve the linker error in C++ compiler
我必须在CPP
编译器中编译PJSIP
。因为我正在将API与PJSIP
进行集成。它在CPP
中。所以我必须使用g++
而不是gcc
。但现在我没有集成任何其他API。
但我在CPP
编译器中得到了链接器错误。如果它是C
编译器,则工作正常。
错误:
架构臂的未定义符号:"_crypto_alloc",引用自:libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_stream_clone(srtp_sttream_ctx_t const*,unsigned int,srtp_stream_ctx_t**(libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_stream_alloc(srtp_sttream_ctx_t**,srtp_policy_t const*(_在libsrtp-arm-apple-darwin9.a中创建srtp_create(srtp.o("_aes_icm_context_init",引用自:libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_kdf_init(srtp_kdf_t*,无符号字符常量*("_crypto_kernel_load_debug_module",引用自:_libsrtp-arm-apple-darwin9.a中的srtp_init(srtp.o("_rdbx_init",引用自:libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_stream_init(srtp_sttream_ctx_t*,srtp_policy_t const*(libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_stream_clone(srtp_sttream_ctx_t const*,unsigned int,srtp_stream_ctx_t**("_key_limit_clone",引用自:libsrtp-arm-apple-darwin9.a(srtp.o(中的srtp_stream_clone(srtp_sttream_ctx_t const*,unsigned int,srtp_stream_ctx_t**("_auth_get_tag_length",引用自:_libsrtp-arm-apple-darwin9.a中的srtp_unprotect_rtcp(srtp.o(_libsrtp-arm-apple-darwin9.a中的srtp_protect_rtcp(srtp.o(_libsrtp-arm-apple-darwin9.a中的srtp_unprotect(srtp.o(_libsrtp-arm-apple-darwin9.a中的srtp_protet(srtp.o(。。。…
事实上,我在makefile
中没有更改任何内容。
注意:在srtp.c
文件中,已经包含了alloc.h
文件。我赞扬并编译了它。我只得到了相同的链接器错误。我有两种想法。但我对此并不确定
1.未与.o
文件链接
2.它没有获取头文件。(我对此不清楚。(
请帮我解决这个问题。
- 不要用C++编译器编译C源代码。只需使用C编译器进行编译,然后使用C++链接器将其链接到您的C++程序中
- 声明
extern "C"
块中的所有C符号;将#include
指令封装在这样的块中,或者将其放在头中。(检查标头中是否已经没有这样的块。(
另请参阅C++常见问题解答中的"如何混合使用C和C++"。
当C
符号在C++
程序中未定义时,意味着它们的声明未标记为extern "C"
。
处理它的标准方法是用包装C
标头
#ifdef __cplusplus
extern "C" {
#endif
// C declarations here
#ifdef __cplusplus
}
#endif
这是pjsip项目中的链接器错误。您是否使用xcode或任何其他IDE来开发此项目?
出现此错误的原因是,上述文件未成功链接到您的项目。
将以下缺少的库文件添加到您的项目中。
=>libsrtp-arm-apple-darwin9.a
按照以下链接将库文件链接到项目中。
来源:https://www.chilkatsoft.com/xcode-link-static-lib.asp
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误