c++ - 错误:没有匹配函数来调用‘PSTUNClient::PSTUNClient

标签 c++ linux centos fedora opalvoip

以下代码总是抛出相同的错误,它似乎在 ubuntu 中有效,但在 fedora/centos 中无效。

2945 void H323EndPoint::SetSTUNServer(const PString & server)
2946 {
2947   natMethods->RemoveMethod("STUN");
2948   delete stun;
2949 
2950   if (server.IsEmpty())
2951     stun = NULL;
2952   else {
2953     stun = new PSTUNClient(server,
2954                            GetUDPPortBase(), GetUDPPortMax(),
2955                            GetRtpIpPortBase(), GetRtpIpPortMax());
2956 
2957     natMethods->AddMethod(stun);
2958 
2959     PTRACE(2, "H323\tSTUN server \"" << server 
              << "\" replies " << stun->GetNatTypeName());
2960 
2961         STUNNatType((int)stun->GetNatType());
2962   }
2963 }
2964 
2965 #endif // P_STUN

尝试的步骤:

$ cd ~
$ cvs -d:pserver:anonymous@openh323gk.cvs.sourceforge.net:/cvsroot/openh323gk login
(just press enter when prompted for password)
$ cvs -z3 -d:pserver:anonymous@openh323gk.cvs.sourceforge.net:/cvsroot/openh323gk co -P openh323gk
$ cd openh323gk
$ ./configure --enable-h46018
$ make optnoshared
make DEBUG= P_SHAREDLIB=0 default_target
make[1]: Entering directory `/root/h323plus'
make[1]: Leaving directory `/root/h323plus'
make -C src optnoshared
make[1]: Entering directory `/root/h323plus/src'
make DEBUG= P_SHAREDLIB=0 default_target
make[2]: Entering directory `/root/h323plus/src'
[CC] h323ep.cxx
h323ep.cxx: In member function ‘PBoolean H323EndPoint::StartListeners(const H323TransportAddressArray&)’:
h323ep.cxx:1107:29: warning: ‘virtual PObject* PAbstractList::RemoveAt(PINDEX)’ is deprecated (declared at /root/ptlib/include/ptlib/lists.h:233)
h323ep.cxx: In member function ‘PBoolean H323EndPoint::RemoveAliasName(const PString&)’:
h323ep.cxx:2750:31: warning: ‘virtual PObject* PAbstractList::RemoveAt(PINDEX)’ is deprecated (declared at /root/ptlib/include/ptlib/lists.h:233)
h323ep.cxx: In member function ‘void H323EndPoint::SetSTUNServer(const PString&)’:
h323ep.cxx:2955:65: error: no matching function for call to ‘PSTUNClient::PSTUNClient(const PString&, WORD, WORD, WORD, WORD)’
/root/ptlib/include/ptclib/pstun.h:441:5: note: candidates are: PSTUNClient::PSTUNClient()
/root/ptlib/include/ptclib/pstun.h:438:1: note:                 PSTUNClient::PSTUNClient(const PSTUNClient&)
/root/ptlib/include/ptlib/sound.h: At global scope:
/root/ptlib/include/ptlib/sound.h:745:1: warning: ‘PPlugin_PSoundChannel_WAVFile_loader’ defined but not used
/root/ptlib/include/ptlib/videoio.h:1165:1: warning: ‘PPlugin_PVideoInputDevice_FakeVideo_loader’ defined but not used
/root/ptlib/include/ptlib/videoio.h:1172:1: warning: ‘PPlugin_PVideoInputDevice_FFMPEG_loader’ defined but not used
/root/ptlib/include/ptlib/videoio.h:1176:1: warning: ‘PPlugin_PVideoInputDevice_YUVFile_loader’ defined but not used
/root/h323plus/include/h460/h460_std18.h:119:1: warning: ‘PPlugin_H460_Feature_Std18_loader’ defined but not used
/root/h323plus/include/h460/h460_std18.h:179:1: warning: ‘PPlugin_H460_Feature_Std19_loader’ defined but not used
/root/h323plus/include/h460/h46018_h225.h:377:1: warning: ‘PPlugin_PNatMethod_H46019_loader’ defined but not used
/root/h323plus/include/h460/h460_std23.h:194:1: warning: ‘PPlugin_H460_Feature_Std23_loader’ defined but not used
/root/h323plus/include/h460/h460_std23.h:278:1: warning: ‘PPlugin_H460_Feature_Std24_loader’ defined but not used
/root/h323plus/include/h460/h460_std9.h:113:1: warning: ‘PPlugin_H460_Feature_Std9_loader’ defined but not used
/root/h323plus/include/h460/h460_oid3.h:181:1: warning: ‘PPlugin_H460_Feature_OID3_loader’ defined but not used
/root/h323plus/include/gnugknat.h:304:1: warning: ‘PPlugin_PNatMethod_GnuGk_loader’ defined but not used
/root/ptlib/include/ptlib/pluginmgr.h:167:1: warning: ‘PFactoryLoader::PluginLoaderStartup_loader’ defined but not used
/root/ptlib/include/ptclib/url.h:479:1: warning: ‘PFactoryLoader::PURL_HttpLoader_loader’ defined but not used
/root/ptlib/include/ptclib/url.h:482:1: warning: ‘PFactoryLoader::PURL_FtpLoader_loader’ defined but not used
make[2]: *** [/root/h323plus/lib/obj_s/h323ep.o] Error 1
make[2]: Leaving directory `/root/h323plus/src'
make[1]: *** [optnoshared] Error 2
make[1]: Leaving directory `/root/h323plus/src'
make: *** [optnoshared] Error 2

最佳答案

编译器告诉您它找不到原型(prototype)为PSTUNClient::PSTUNClient(const PString&, WORD, WORD, WORD, WORD)<的PSTUNClient 类的构造函数.

这些是错误输出中的相关行:

h323ep.cxx:2955:65: error: no matching function for call to ‘PSTUNClient::PSTUNClient(const PString&, WORD, WORD, WORD, WORD)’
/root/ptlib/include/ptclib/pstun.h:441:5: note: candidates are: PSTUNClient::PSTUNClient()
/root/ptlib/include/ptclib/pstun.h:438:1: note:                 PSTUNClient::PSTUNClient(const PSTUNClient&)

在您的代码中,这一行:

stun = new PSTUNClient(server,
                       GetUDPPortBase(), GetUDPPortMax(),
                       GetRtpIpPortBase(), GetRtpIpPortMax());

...是导致错误的原因。

您可能正在尝试使用不存在的构造函数。编译器提示您改用 PSTUNClient::PSTUNClient()

stun = new PSTUNClient();

如果这在您的 ubuntu 构建中编译而不是 fedora,请问问自己是否在两个构建中使用相同版本的 PSTUN 库。

关于c++ - 错误:没有匹配函数来调用‘PSTUNClient::PSTUNClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5930897/

相关文章:

bash - 打印 IP 范围内的所有 IP 地址 ssh/bash

r - 无法在 Centos 7 中安装 R

c++ - 如何将 2 个独立的 boost::bind() 组合成一个 boost::function?

c++ - 试图让简单的 ODB 'hello' 程序工作

c++ - 如何将文件中的日期时间解析为 C++ 中的类

c - 编写 C 动态库 [DSOs] 的良好实践(二进制兼容性 + 内存管理)

c - 在 Linux 内核中启用调度程序统计信息

c++ - 在表达式树中添加一元运算符

linux - 我怎样才能看到这个 RUN_CMD 定义

python - 使用默认 python 解释器而不是安装 virtualenv 解释器的网站