[英]How do I approach this Linux C++ warning? “can't find linker symbol for virtual table for `sockaddr_in'”
Ubuntu 10.04 32-bit, eclipse, C and C++ Ubuntu 10.04 32位,eclipse,C和C ++
I have a program that uses select() to monitor a bunch of TCP and UDP ports. 我有一个程序,使用select()来监视一堆TCP和UDP端口。 I create those ports in the usual way (socket(), bind(), listen(), accept() etc.) using sockaddr_in structures.
我使用sockaddr_in结构以通常的方式创建这些端口(socket(),bind(),listen(),accept()等)。
The program works fine at the command line. 该程序在命令行正常工作。 I was using the eclipse debugger to fix a bug (fixed now!) when I noticed the following warning:
当我注意到以下警告时,我正在使用eclipse调试器来修复错误(现在修复!):
warning: can't find linker symbol for virtual table for `sockaddr_in' value
warning: found `operator delete(void*)' instead
Well, after fixing my bug I checked and the warning persisted. 好吧,在修复我的错误后,我检查了警告并且仍然存在。
I know that the warnings commence as soon as I enter my ConfigureServer() routine where the ports/sockets get connected. 我知道一旦我进入我的ConfigureServer()例程,端口/套接字连接,警告就会开始。 The sockaddr_in structures are declared in the routine and are on the stack.
sockaddr_in结构在例程中声明并且在堆栈中。 In fact, nothing in the program is yet in the heap.
事实上,程序中还没有任何内容。 This is a mix of C and C++ with no objects declared or used up to this point.
这是C和C ++的混合,没有声明或使用到目前为止的对象。
This is the beginning odf the routine. 这是常规的开始。 There are several additional identical bits for other ports.
其他端口还有几个相同的位。
int configureServer()
{
sockaddr_in servAddr;
memset(&servAddr, 0, sizeof(servAddr));
servAddr.sin_family = AF_INET;
servAddr.sin_port = htons( g_tcpPorts[0].serverPort );
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
/* Create and initialize the TCP socket */
if (( g_tcpPorts[0].serverSock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) < 0 )
{
PLOG( ERROR ) << "failed to acquire a socket for IO Control Server port: " << g_tcpPorts[0].serverPort;
return -1; // caller will CloseAllPorts();
}
// ...........
}
So, my question is, how do I debug and track down the cause of these warnings. 所以,我的问题是,如何调试和追踪这些警告的原因。
Thanks, 谢谢,
GDB is still less than perfect, especially when it comes to debugging C++ code. GDB仍然不太完美,特别是在调试C ++代码时。
In this case, sockaddr_in
is "plain old data" (a C struct without any C++ features). 在这种情况下,
sockaddr_in
是“普通旧数据”(没有任何C ++特性的C结构)。 It does not need and should not have any virtual table. 它不需要也不应该有任何虚拟表。 If GDB thinks otherwise, that's a problem with GDB.
如果GDB不这么认为,那就是GDB的问题。
There are two bugs open in GDB bug database that quite this exact message (for different structs/classes). 在GDB错误数据库中有两个错误,这个错误信息 (针对不同的结构/类)。 I would not worry about it too much unless it gets in the way of your debugging.
除非它妨碍你的调试,否则我不会太担心它。
Try maybe using extern "C" before including the headers that declare the sockadd_in struct. 在包含声明sockadd_in结构的头文件之前,尝试使用extern“C”。
extern "C"
{
# include <netinet/in.h>
}
That will probably insure sockaddr_in won't have or need a vtab. 这可能会确保sockaddr_in不会或不需要vtab。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.