2

Trying to build Qt 5.6 from source on Windows 7 using MSVC13. Compilation goes fine, but I get two linker errors regarding multiply defined symbols:

Qt5SerialBus.lib(qmodbusdevice.obj) : error LNK2005: "class QLoggingCategory const & __cdecl QT_MODBUS(void)" (?QT_MODBUS@@YAAEBVQLoggingCategory@@XZ) already defined in mainwindow.obj
Qt5SerialBus.lib(qmodbusdevice.obj) : error LNK2005: "class QLoggingCategory const & __cdecl QT_MODBUS_LOW(void)" (?QT_MODBUS_LOW@@YAAEBVQLoggingCategory@@XZ) already defined in mainwindow.obj
release\adueditor.exe : fatal error LNK1169: one or more multiply defined symbols found

I suspect the problem (and solution) are similar to this one in which the offending functions can just be marked inline, however I can't find the definitions for these two functions anywhere in the modbus code. Does anyone know where "QT_MODBUS" and "QT_MODBUS_LOW" are defined, or is there another workaround to this?

Community
  • 1
  • 1
Carlton
  • 4,217
  • 2
  • 24
  • 40
  • Apparently they are defined in `mainwindow.obj`. Is it from one of your source files? What do you do in that source file that could have caused these functions to be defined? – Some programmer dude Mar 25 '16 at 15:29
  • `mainwindow.obj` isn't mine; it's from some example subproject that is included with the Qt source code. I looked in the `mainwindow.cpp` associated with the "adueditor.exe" but I have not been able to find `QT_MODBUS` or `QT_MODBUS_LOW` in any of it's `#include`s. – Carlton Mar 25 '16 at 15:32
  • Just tried building a fresh source download today, and encountered the same thing with Visual Studio 2015 - so it seems to be a general problem. – ZXcvbnM Mar 27 '16 at 14:03
  • If you dont need examples and tools, you can compile according to [these instructions](https://wiki.qt.io/How_to_prevent_Qt_from_compiling_code_examples). I decline to call it an answer though, since it just avoids rather than fixes the problem. – Carlton Mar 27 '16 at 14:59

0 Answers0