0

I've tried unsuccessfully to correct the error.

Any help would be appreciated.

After correcting another compilation bug the source code compiles to 100% but then throws an undefined reference to vtable error listed below.

Searching online for "undefined reference for vtable" returns various results.

This error appears linked with:

  • compilation error by QMake and CMake (sometimes fixed by re-running make command)
  • missing destructor
  • Q_Object declarations made in .cpp files
  • Q macros in .cpp files

Project:

https://github.com/a-ilin/vidalia

Compiler:

  • CMake

Compilation Error:

[ 98%] Building CXX object src/vidalia/CMakeFiles/vidalia.dir/vidalia_autogen/PNK5WDWK6L/qrc_vidalia.cpp.o
[ 98%] Building CXX object src/vidalia/CMakeFiles/vidalia.dir/vidalia_autogen/ZY6QLEUMHC/qrc_content.cpp.o
[100%] Building CXX object src/vidalia/CMakeFiles/vidalia.dir/vidalia_autogen/O3VI4VFR3H/qrc_vidalia_i18n.cpp.o
[100%] Linking CXX executable vidalia
/usr/bin/ld: CMakeFiles/vidalia.dir/Vidalia.cpp.o: in function VidaliaNativeEventFilter::VidaliaNativeEventFilter()': Vidalia.cpp:(.text._ZN24VidaliaNativeEventFilterC2Ev[_ZN24VidaliaNativeEventFilterC5Ev]+0x1f): undefined reference to vtable for VidaliaNativeEventFilter'
collect2: error: ld returned 1 exit status
make[2]: *** [src/vidalia/CMakeFiles/vidalia.dir/build.make:2105: src/vidalia/vidalia] Error 1
make[1]: *** [CMakeFiles/Makefile2:598: src/vidalia/CMakeFiles/vidalia.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Files that appear to be the cause of the error

https://github.com/a-ilin/vidalia/blob/alpha-qt5/src/vidalia/Vidalia.h
https://github.com/a-ilin/vidalia/blob/alpha-qt5/src/vidalia/Vidalia.cpp

Lines L112, L115, L128, L227 contain "VidaliaNativeEventFilter" in Vidalia.cpp

Code snippet
Line 109 - Line 129

/** Provides native event filtering with Qt5
 */
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
class VidaliaNativeEventFilter : public QAbstractNativeEventFilter
{
public:
  VidaliaNativeEventFilter()
    : QAbstractNativeEventFilter() {}

  bool nativeEventFilter(const QByteArray& eventType, void* message, long* result);
};
#endif

/** Constructor. Parses the command-line arguments, resets Vidalia's
 * configuration (if requested), and sets up the GUI style and language
 * translation. */
Vidalia::Vidalia(QStringList args, int &argc, char **argv)
: QApplication(argc, argv)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, _nativeEventFilter(new VidaliaNativeEventFilter())
#endif

Code snippet
Line 218 - Line 242

/** On Windows, we need to catch the WM_QUERYENDSESSION message
 * so we know that it is time to shutdown. */
#if defined(Q_OS_WIN)
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
bool
Vidalia::winEventFilter(MSG* msg, long* result)
{
#else
bool
VidaliaNativeEventFilter::nativeEventFilter(const QByteArray& /*eventType*/, void* message, long* result)
{
  MSG* msg = (MSG*)message;
#endif

  if (msg && (msg->message == WM_QUERYENDSESSION)) {
    QApplication::quit();
  }

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
  return QApplication::winEventFilter(msg, result);
#else
  return false;
#endif
}
#endif
Yun
  • 3,056
  • 6
  • 9
  • 28
tulip
  • 1
  • 1
  • Please re-open the question. I included as much information as possible and was asking for help because there was no clear answer on existing posts of how to fix this issue. – tulip Sep 22 '21 at 22:32
  • 1. Do not edit your post to put information that you already put in the comments, is noise, 2. If you want help you must provide an MRE, external links are not part of an MRE. Please read [ask] to improve your post. – eyllanesc Sep 22 '21 at 22:36
  • @eyllanesc can you please re-open the question. I've gone through 20+ stackoverflow posts and none of the solutions provided fixed the compilation error – tulip Sep 22 '21 at 22:41
  • If you don't provide an MRE([mre]) then I won't be able to reopen your post – eyllanesc Sep 22 '21 at 22:42
  • I provided a minimal reproducible example. The compilation error was listed. I documented the compiler, included code snippets. Original files were linked – tulip Sep 22 '21 at 22:44
  • No, that is not an MRE. Please read the link. – eyllanesc Sep 22 '21 at 22:44
  • @eyllanesc How would you create an MRE for this submission that you would find acceptable? I included the cmake compiler output showing the build error. I linked the original full files but also included code snippets to lines in vidalia.cpp that referenced "VidaliaNativeEventFilter". That is as minimal as possible. I came here for help because this is not my area of expertise. – tulip Sep 22 '21 at 22:50
  • Do not look at the most trivial characteristic of the MRE: the minimum, the easiest to obtain since it only involves eliminating code. Focus on what is important: reproducibility, that is, any user can copy, paste and execute in order to reproduce the same error and that you have not provided. Minimal does not imply less code but the code necessary to reproduce the error. – eyllanesc Sep 22 '21 at 22:56
  • @eyllanesc The compiler error cited "VidaliaNativeEventFilter". A grep of the entire master branch returned four results in vidalia.cpp on the lines stated in the original unedited post. That's as minimum as possible. I included code snippets of those lines to permit a review of the class and functions. I further linked the vidalia.cpp and vidalia.h files for review and the full project hosted at github so anyone can attempt to reproduce the error when compiling the source code. As stated this is not my area of expertise. If I was a QT5 programmer I would not be here asking for help. – tulip Sep 22 '21 at 23:02
  • 1. An MRE should not depend on an external resource, 2. Here it does not matter if you are an expert or a beginner in any technology, in all cases the same rules apply. Also review the [tour]. Bye – eyllanesc Sep 22 '21 at 23:05

0 Answers0