[fixed] [regression] [TD] not compilable

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

[fixed] [regression] [TD] not compilable

Post by uwestoehr »

Compiling current master brings me this error:

Code: Select all

2>------ Build started: Project: TechDrawGui, Configuration: Release x64 ------
2>Automatic MOC for target TechDrawGui
2>FreeCADGui.lib(FreeCADGui.dll) : error LNK2005: "public: __cdecl Base::Observer<char const *>::Observer<char const *>(void)" (??0?$Observer@PEBD@Base@@QEAA@XZ) already defined in QGIView.obj
2>FreeCADGui.lib(FreeCADGui.dll) : error LNK2005: "public: virtual __cdecl Base::Observer<char const *>::~Observer<char const *>(void)" (??1?$Observer@PEBD@Base@@UEAA@XZ) already defined in QGIView.obj
2>   Creating library D:/FreeCAD-build/src/Mod/TechDraw/Gui/Release/TechDrawGui.lib and object D:/FreeCAD-build/src/Mod/TechDraw/Gui/Release/TechDrawGui.exp
2>D:\FreeCAD-build\Mod\TechDraw\TechDrawGui.pyd : fatal error LNK1169: one or more multiply defined symbols found
2>Done building project "TechDrawGui.vcxproj" -- FAILED
I recompiled from scratch and even on two different PCs with different MSVC versions.

Bisecting leads to

Code: Select all

9894964eb69e9014f6f14afbf9188b0477cb7fc8 is the first bad commit
commit 9894964eb69e9014f6f14afbf9188b0477cb7fc8
Author: Wanderer Fan <wandererfan@gmail.com>
Date:   Fri Apr 8 19:24:15 2022 -0400

[TD]implement navigation styles
@wandererfan , can you please have a look?
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [regression] [TD] not compilable

Post by wandererfan »

uwestoehr wrote: Sat Jun 25, 2022 12:13 am Compiling current master brings me this error:
Master compiles here on Linux.

i don't have a Win environment at the moment, so this will be difficult for me to figure out.

If I understand the message correctly, the ctor and dtor of Base::Observer are declared multiple times?? And one of those declarations is in QGIView?

The commit you referenced adds "ParameterGrp::ObserverType" as an ancestor of QGVPage. We could try removing that and "virtual void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override;" to see if that is causing the issue.

MDIViewPage has Gui::SelectionObserver as an ancestor, but that isn't new.

Those are the only uses of Observer in TechDrawGui.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [regression] [TD] not compilable

Post by uwestoehr »

wandererfan wrote: Sat Jun 25, 2022 5:03 pm We could try removing that and "virtual void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override;" to see if that is causing the issue.
Unfortunately I did not yet understand what you mean. Could you please make a PR that I can either test or at least get the idea?
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [regression] [TD] not compilable

Post by wandererfan »

uwestoehr wrote: Sat Jun 25, 2022 5:07 pm Unfortunately I did not yet understand what you mean. Could you please make a PR that I can either test or at least get the idea?
commented out the parameter observer stuff here:
https://github.com/FreeCAD/FreeCAD/pull/7097
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [regression] [TD] not compilable

Post by uwestoehr »

wandererfan wrote: Sat Jun 25, 2022 5:37 pm commented out the parameter observer stuff here:
https://github.com/FreeCAD/FreeCAD/pull/7097
Thanks! I tested this and it compiles.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [regression] [TD] not compilable

Post by wandererfan »

uwestoehr wrote: Sat Jun 25, 2022 7:56 pm Thanks! I tested this and it compiles.
I wonder why this works:

Code: Select all

class GuiExport View3DInventor : public MDIView, public ParameterGrp::ObserverType
{
...
    /// Observer message from the ParameterGrp
    virtual void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason);
And this does not:

Code: Select all

class TechDrawGuiExport QGVPage : public QGraphicsView, public ParameterGrp::ObserverType
{
...
    /// Observer message from the ParameterGrp
    virtual void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override;
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [regression] [TD] not compilable

Post by wandererfan »

uwestoehr wrote: Sat Jun 25, 2022 7:56 pm
Could you try this again, please? I've pushed a commit with conditional compile flags so the ParameterObserver is not used in WIN, but is still used in Linux.

Thanks.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [regression] [TD] not compilable

Post by openBrain »

wandererfan wrote: Sat Jun 25, 2022 8:36 pm I wonder why this works:

And this does not:
With a mobile now so can't really check, but could that be that the superclass method is defined as pure virtual, so you override nothing but actually define :?:
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [regression] [TD] not compilable

Post by wmayer »

The current master compiles fine on Linux and with clang on MSYS/MinGW. It's only the MSVC compiler that sucks.

According to the linker error I guess what happens is that the compiler generates multiple definitions of the template class Base::Observer with the template parameter being "const char*". Maybe it already helps to change the include order in QGIView.cpp by including QGIView.h before QGVPage.h.
Alternatively, doing an explicit template instantiating of Base::Observer<const char*> in FreeCADBase should help.

EDIT: Unfortunately none of them solves the issue.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [regression] [TD] not compilable

Post by uwestoehr »

wandererfan wrote: Sat Jun 25, 2022 11:59 pm Could you try this again, please? I've pushed a commit with conditional compile flags so the ParameterObserver is not used in WIN, but is still used in Linux.
Done. But now it does not compile:

Code: Select all

2>QGVPage.cpp
2>D:\FreeCAD-build\src\Mod\TechDraw\Gui\TechDrawGui_autogen\include_Release\Mod/TechDraw/Gui/moc_QGVPage.cpp(101,62): error C2440: 'static_cast': cannot convert from 'TechDrawGui::QGVPage *' to 'Base::Observer<_MessageType> *'
2>        with
2>        [
2>            _MessageType=const char *
2>        ]
2>D:\FreeCAD-build\src\Mod\TechDraw\Gui\TechDrawGui_autogen\include_Release\Mod/TechDraw/Gui/moc_QGVPage.cpp(101,16): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
2>Done building project "TechDrawGui.vcxproj" -- FAILED.
Post Reply