C++ 未知的警告来源:“;can';“找不到虚拟表的链接器符号…”;

C++ 未知的警告来源:“;can';“找不到虚拟表的链接器符号…”;,c++,eclipse,gcc,gdb,warnings,C++,Eclipse,Gcc,Gdb,Warnings,几天以来,我在调试时收到一条警告消息。我找不到它是从哪里来的。我已经在谷歌上搜索过了,发现这是因为我有一个静态变量。但是把它拿出来并不能改变任何事情 这是main方法: int main(int argc, char* argv[]) { if (argc != 2) { cout << "ERROR: Wrong amount of arguments!...\n" << endl; cout <&

几天以来,我在调试时收到一条警告消息。我找不到它是从哪里来的。我已经在谷歌上搜索过了,发现这是因为我有一个静态变量。但是把它拿出来并不能改变任何事情

这是
main
方法:

int main(int argc, char* argv[]) {
    if (argc != 2) {
        cout << "ERROR: Wrong amount of arguments!...\n"
             << endl;
        cout << "\n" << "Programm closed...\n\n" << endl;
    cin.ignore();
    exit(1);
    return 0;
    }

    cout << "argv[1] " << argv[1] << endl;

    GenericCommandConverter a(argv[1]);
    a.getCommandsFromCSV();

    cout << "\n" << "Programm finished...\n\n" << endl;

    return 0;
}
[New Thread 2000.0x11bc]
warning: can't find linker symbol for virtual table for
`std::less<std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char, 
std::char_traits<char>,     std::allocator<char> > > > >' value
intmain(intargc,char*argv[]){
如果(argc!=2){

cout消息来自
gdb/gnu-v3-abi.c
中的此代码:

static struct type *
gnuv3_rtti_type (struct value *value,
                 int *full_p, int *top_p, int *using_enc_p)
{
...
  /* The symbol's demangled name should be something like "vtable for
     CLASS", where CLASS is the name of the run-time type of VALUE.
     If we didn't like this approach, we could instead look in the
     type_info object itself to get the class name.  But this way
     should work just as well, and doesn't read target memory.  */
  vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);
  if (vtable_symbol_name == NULL
      || strncmp (vtable_symbol_name, "vtable for ", 11))
    {
      warning (_("can't find linker symbol for virtual table for `%s' value"),
               TYPE_NAME (values_type));
      if (vtable_symbol_name)
        warning (_("  found `%s' instead"), vtable_symbol_name);
      return NULL;
    }
现在,我相当肯定
std::less
一开始不应该有一个虚拟表,所以GDB很可能被搞糊涂了

您需要验证最新的GDB是否存在问题,并提交一个bug


由于这是最近才开始的,您是否升级了您的GCC、GDB或更改了编译标志?

回答了问题标题,但没有回答OP的问题(因为web搜索让我想到了这一点):同样消息的另一个来源是GDB可能会被尚未初始化的变量弄糊涂

当然,不应该有未初始化的变量,但在我的例子中,gdb甚至在声明/初始化函数局部变量之前就尝试显示它们

今天,我正在处理另一个开发人员的gtest案例,每次调试器停止时,都会将此消息转储到输出中。在本例中,相关变量在第245行声明,但函数在第202行启动。每次我在这两行之间停止调试器时,都会收到此消息

我通过将变量声明移到函数顶部来解决这个问题


作为参考,我正在使用QtCreator 4.1.0中的gdb 7.11.1版进行测试,我使用g++5.4.1版编译了一个完整的包含、定义和完整的源代码列表,以及控制台输出。这实际上是完整的输出,其他内容不显示。我将添加头文件…我甚至尝试了crea暂停一个新项目并插入代码,以避免项目设置中出现有趣的内容。但它一直在做相同的事情…您可以尝试用谷歌搜索
gdb找不到虚拟表的链接器符号,因为gdb是Eclipse中使用的调试器我已经在做了…但到目前为止没有任何帮助…:(嘿,谢谢!在MinGW上有了更新的版本,它现在就可以工作了。我在4.5.1之前更新到了4.5.2,我认为它不会影响它,因为eclipse使用它自己的调试器…真是太感谢你了!我认为eclipse的调试器只解析gdb输出。
#ifndef CommandConverter_H_
#define CommandConverter_H_

#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <iosfwd>
#include <map>
#include <vector>
#include <cstdio>

using namespace std;

class CommandConverter {
public:
    CommandConverter(char* file);
    virtual ~CommandConverter();

    void printConvertedTraceByPage(vector<string> lines);

    map<string, vector<map<vector<string> , vector<string> > > > csvMap;
    static const int MAX_SIZE = 5;

    void getATCommandsFromCSV();
    string readTxtFile();
    vector<string> splitIntoLines(const char* trace);
    vector<string> convert(vector<string> fileInLines);

    bool commandAvailable(const char* l, int pos, const char* s);
    void error(const char* p, const char* p2);
    void printCSV();

    // opened in constructor; closed in destructor
    ifstream myfile;
    string filename;
    string trace_raw;
};

#endif /* CommandConverter_H_ */
static struct type *
gnuv3_rtti_type (struct value *value,
                 int *full_p, int *top_p, int *using_enc_p)
{
...
  /* The symbol's demangled name should be something like "vtable for
     CLASS", where CLASS is the name of the run-time type of VALUE.
     If we didn't like this approach, we could instead look in the
     type_info object itself to get the class name.  But this way
     should work just as well, and doesn't read target memory.  */
  vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);
  if (vtable_symbol_name == NULL
      || strncmp (vtable_symbol_name, "vtable for ", 11))
    {
      warning (_("can't find linker symbol for virtual table for `%s' value"),
               TYPE_NAME (values_type));
      if (vtable_symbol_name)
        warning (_("  found `%s' instead"), vtable_symbol_name);
      return NULL;
    }