Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Two or more QObject-based classes having the same name put in different namespaces
Forum Updated to NodeBB v4.3 + New Features

Two or more QObject-based classes having the same name put in different namespaces

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 596 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • napajejenunedk0N Offline
    napajejenunedk0N Offline
    napajejenunedk0
    wrote on last edited by
    #1

    Hello, all. I am having the aforementioned situation. My project includes two or more QObject-based classes that are situated both in different folders and different namespaces. The problem is that at linker stage I receive the following errors:

    Widget.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl Inner::Widget::metaObject(void)const " (?metaObject@Widget@Inner@@UEBAPEBUQMetaObject@@XZ)
    Widget.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl Inner::Widget::qt_metacast(char const *)" (?qt_metacast@Widget@Inner@@UEAAPEAXPEBD@Z)
    Widget.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl Inner::Widget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Widget@Inner@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
    debug\TestQmake.exe : fatal error LNK1120: 3 unresolved externals
    

    These are the build errors output having already configured the project this way:

    CONFIG += object_parallel_to_source no_batch
    

    so that the output intermediate binaries - .obj files, are not put in a single directory no matter the sources are hierarchically spread, but to use the same hierarchical structure for the intermediate binaries as that of the sources. Another option is to replace object_parallel_to_source with object_with_source - https://wiki.qt.io/Undocumented_QMake. Saw, that there is already a forum topic concerning exactly the same problem but it is 2+ years old. There are also other posts on the case - #1, #2.

    The actual problem is that as mentioned by @JKSH in the first aforementioned forum topic:
    Hi,
    Unfortunately the meta-object compiler doesn't handle namespaces.
    This has been discussed before, and some workarounds proposed: http://www.qtcentre.org/threads/6753-moc-with-same-file-names

    Is there now a more flexible solution instead of renaming the classes?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved