eclipse 未知的警告来源:“找不到虚拟表的链接器符号...”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4721648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:40:00  来源:igfitidea点击:

Unknown source of warning: "can't find linker symbol for virtual table for..."

c++eclipsegccgdbwarnings

提问by Beasly

Since a few days I'm getting a warning msg while debugging. I can't find where it comes from. I was googleing already and found things like it's because I have a static variable. But taking it out doesn't change anything.

几天以来,我在调试时收到警告消息。我找不到它来自哪里。我已经在谷歌搜索并发现了类似的东西,因为我有一个静态变量。但是取出来并没有什么改变。

This is the mainmethod:

这是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;
}

The code where it occures first time:

第一次出现的代码:

void GenericCommandConverter::getATCommandsFromCSV() {

    cout << "+++++++++++getCommandsFromCSV) started++++++++++++++" << endl;

    string filename_csv = "test.csv";
    string commands = "";
   int pos_start = 0;
    int pos_end = 0;
    int substrLength = 0;
    int separator_count = 0;

    char c;

    vector<string> lines;
    vector<string> commandList;
    vector<unsigned int> parameterPositionList;
    vector<vector<string> > linesSeparated;
    vector<vector<string> > part1_input;
    vector<vector<string> > part2_output;
    vector<map<vector<string> , vector<string> > > listedParameterMap;

    ifstream csvFile;
    csvFile.open(filename_csv.c_str(), ios_base::in);

    cout << "i'm starting getCommandsFromCSV()...\n" << endl;

    /**
     * STEP 1
     * Putting input text file into a string
     */
    if (csvFile.is_open()) {
        while (!csvFile.eof()) { // <------- warning occurs here!
                csvFile.get(c);
            commands += c;
    }

...

}

}

Warning:

警告:

[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

Does anyone know why this is comming? It comes with each line until it started. It filles the console so much that it's not possible to debug. Another maybe important info on standalone mode this error is not displayed.

有谁知道这是为什么?它伴随着每一行,直到它开始。它填满了控制台,以至于无法调试。关于独立模式的另一个可能重要的信息是不显示此错误。

I really would appreciate some help!

我真的很感激一些帮助!

EDIT:header file

编辑:头文件

#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_ */

回答by Employed Russian

The message comes from this code in gdb/gnu-v3-abi.c:

该消息来自以下代码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;
    }

Now, I am fairly sure std::lessisn't supposed to have a virtual table in the first place, so it's likely that GDB is confused.

现在,我很确定一开始std::less就不应该有虚拟表,所以 GDB 很可能会感到困惑。

You'd need to verify that the problem exists with the latest GDB, and file a bug.

您需要验证最新的 GDB 是否存在问题,并提交错误。

Since this only started recently, have you upgraded your GCC, GDB, or changed compilation flags?

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

回答by sage

Answering the question title, but not the OP's question (since a web search led me here): another source of this same message is that gdb can get confused by not-yet-initialized variables.

回答问题标题,但不是 OP 的问题(因为网络搜索将我带到这里):同一消息的另一个来源是 gdb 可能会被尚未初始化的变量混淆。

Naturally, you shouldn't have uninitialized variables, but in my case gdb attempts to show function local variables even before they are declared/initialized.

自然,您不应该有未初始化的变量,但在我的情况下,gdb 甚至在声明/初始化之前尝试显示函数局部变量。

Today I'm stepping through another developer's gtest case and this message was getting dumped to output every time the debugger stopped. In this case, the variable in question was declared on ~line 245, but the function started on ~line 202. Every time I stopped the debugger between these lines, I received the message.

今天我正在逐步完成另一个开发人员的 gtest 案例,每次调试器停止时,这条消息都会被转储到输出。在这种情况下,有问题的变量在 ~line 245 上声明,但函数在 ~line 202 上启动。每次我在这些行之间停止调试器时,我都会收到消息。

I worked around the issue by moving the variable declaration to the top of the function.

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

For reference, I am testing with gdb version 7.11.1 in QtCreator 4.1.0 and I compiled with g++ version 5.4.1

作为参考,我在 QtCreator 4.1.0 中使用 gdb 7.11.1 版进行测试,并使用 g++ 5.4.1 版进行编译