使用 PjSip {PJSUA} 编译 Opus 库时出错

Error while Compiling Opus Library with PjSip {PJSUA}

我正在尝试编译和构建 PjProject {PJSUA},其中包含 音频和视频支持。但是每次都陷入错误Unresolved_External_Symbols.

我正在使用 Visual Studio 2022 为 Windows-32-BIT 构建此项目,工具链设置最新版本 v143。

我想初始化各种编解码器{OPUS、OPENH264、FFMPEG、OPENSSL、SDL 等}。我只问 OPUS LIBRARY.

步骤如下:

  1. 已获取最新版 PjProject 的源码并于 Visual Studio 2022 年加载项目。

  2. 在编译和构建 LibOpus 后提及 Opus Include 目录和 Opus Library 目录。

  3. 将 PJSUA 作为源项目并将配置设置为 Debug-Static-Win32 并开始构建项目。

注意

我在错误日志中收到的错误如下:

Error   LNK2019 unresolved external symbol _opus_encoder_get_size referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_encoder_init referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_encode referenced in function _pjmedia_codec_opus_set_default_param    pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_encoder_ctl referenced in function _pjmedia_codec_opus_set_default_param   pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_decoder_get_size referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_decoder_init referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_decode referenced in function _pjmedia_codec_opus_set_default_param    pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_packet_get_nb_samples referenced in function _pjmedia_codec_opus_set_default_param pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_get_size referenced in function _pjmedia_codec_opus_set_default_param pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_init referenced in function _pjmedia_codec_opus_set_default_param pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_cat referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_out_range referenced in function _pjmedia_codec_opus_set_default_param    pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_get_nb_frames referenced in function _pjmedia_codec_opus_set_default_param    pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK2019 unresolved external symbol _opus_repacketizer_out referenced in function _pjmedia_codec_opus_set_default_param  pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\build\libpjproject-i386-Win32-vc14-Debug-Static.lib(opus.obj)    1
Error   LNK1120 14 unresolved externals pjsua   C:\Users\coral\Desktop\pjproject-master\pjsip-apps\bin\pjsua-i386-Win32-vc14-Debug-Static.exe   1

我能否找到一种更简单的方法,以便我可以通过保存它来消除所有这些错误,并编译和构建我的 PJSUA,其中包含 OPUS CODEC。

经过长时间的尝试,我得到如下解决方案:

  1. 在config_site.h中我们需要提及并激活我们的编解码器以进行编译#define PJMEDIA_HAS_OPUS_CODEC

#define PJMEDIA_HAS_OPUS_CODEC 必须在整个程序和剩余函数行中处于活动状态,即 #define PJMEDIA_HAS_OPUS_CODEC 1 必须从程序中明确删除,以便于编译,这将忽略在构建过程中调用的不同函数。

I would still refer that while building on windows use Microsoft Visual Studio latest Version along with the latest toolset to compile and built different programs for a Single Linker.