warning message RTTI symbol not found when using boost::iostreams

喜欢而已 提交于 2020-01-14 08:59:12

问题


I use Boost::iostreams to write simultaneously to my console and a file. When i use eclipse to debug(with gdb of course), i receive a warning which says RTTI symbol not found for one of the classes that i am using from Boost::iostreams.

Here is the minimal code to reproduce the problem.

#ifndef BOOST_IO_STREAM_H_
#define BOOST_IO_STREAM_H_

#include <fstream>
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
using boost::iostreams::tee_device;
using boost::iostreams::stream;

typedef tee_device<std::ostream, std::ofstream> TeeDevice;
typedef stream<TeeDevice> TeeStream;

#endif /* BOOST_IO_STREAM_H_ */

int
main()
{

  /* A config file to output experiment details */
  std::string self_filename = "./experimentconfig.txt";
  std::ofstream fconfig(self_filename.c_str());
  TeeDevice my_tee(std::cout, fconfig);
  TeeStream cool_cout(my_tee);

  cool_cout << "Output to file and console during experiment run" << std::endl;

  return 0;
}

When i cross the TeeStream cool_cout(my_tee); line during debugging, i receive the below warnings:

warning: RTTI symbol not found for class 'boost::iostreams::stream<boost::iostreams::tee_device<std::ostream, std::basic_ofstream<char, std::char_traits<char> > >, std::char_traits<char>, std::allocator<char> >'
warning: RTTI symbol not found for class 'boost::iostreams::stream_buffer<boost::iostreams::tee_device<std::ostream, std::basic_ofstream<char, std::char_traits<char> > >, std::char_traits<char>, std::allocator<char>, boost::iostreams::output>'

The warnings are repeated whenever the object cool_cout is encountered. How do i fix this? Of course, the programs which use this code works and i have no issues with that. Warnings are not supposed to be ignored and there is some knowledge out there about RTTI symbols which has to be gained. (I cannot compile with -f nortti then the executable complains that rtti should definitely be enabled to use iostreams)


回答1:


Warnings you should be concerned about are from the compiler, which is what actually creates your program. End users should not be using a debugger, and it has no impact on your binary itself.

While gdb sometimes finds issues, many of the warnings in it are because gdb consumes debug symbols, and the consumer (gdb) has bugs and defencencies . Often they just reduce the functionality of gdb. In this case there is less information about that class available inside the debugger. It makes debugging more difficult, but doesn't hurt the application itself.

You have several choices for what to do about this error.

  1. Ignore the warning in gdb and go on with life.
  2. Get the sources for gdb and try to find the problem and submit a patch. I am sure it would be welcomed.
  3. Use a different debugger. (All alternates I have seen are paid products though.)
  4. Rewrite the program to not use any templates. gdb template handling is where the majority of symbol lookup issues exist.


来源:https://stackoverflow.com/questions/12986261/warning-message-rtti-symbol-not-found-when-using-boostiostreams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!