WtDesigner icon indicating copy to clipboard operation
WtDesigner copied to clipboard

Qt5 Wt4 porting effort

Open ppetraki opened this issue 4 years ago • 8 comments

So I have all the header files sorted but the build is failing with the strangest error somewhere inside the Wt lib. You probably know that lib better than I do so I want to get your opinion on it.

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o helperfunctions.o main/helperfunctions.cpp
In file included from /usr/local/include/Wt/WSignal.h:14:0,
                 from /usr/local/include/Wt/WWidget.h:14,
                 from /usr/local/include/Wt/WWebWidget.h:14,
                 from /usr/local/include/Wt/WInteractWidget.h:10,
                 from /usr/local/include/Wt/WContainerWidget.h:10,
                 from main/helperfunctions.h:43,
                 from main/helperfunctions.cpp:18:
/usr/local/include/Wt/Signals/signals.hpp:216:18: error: expected ‘)’ before ‘...’ token
   void emit (Args... args) const
                  ^~~
In file included from /usr/local/include/Wt/WWidget.h:14:0,
                 from /usr/local/include/Wt/WWebWidget.h:14,
                 from /usr/local/include/Wt/WInteractWidget.h:10,
                 from /usr/local/include/Wt/WContainerWidget.h:10,
                 from main/helperfunctions.h:43,
                 from main/helperfunctions.cpp:18:
/usr/local/include/Wt/WSignal.h:330:14: error: expected ‘)’ before ‘...’ token
   void emit(A... args) const;
              ^~~
/usr/local/include/Wt/WSignal.h:658:15: error: expected ‘)’ before ‘e’
   void emit(E e = NoClass()) const;
               ^
/usr/local/include/Wt/WSignal.h:758:24: error: expected unqualified-id before ‘(’ token
 void Signal<A...>::emit(A... args) const
                        ^
/usr/local/include/Wt/WSignal.h: In member function ‘void Wt::Signal<A>::operator()(A ...) const’:
/usr/local/include/Wt/WSignal.h:766:15: error: expected binary operator before ‘)’ token
   emit(args...);
               ^
/usr/local/include/Wt/WSignal.h: At global scope:
/usr/local/include/Wt/WSignal.h:895:26: error: expected unqualified-id before ‘(’ token
 void EventSignal<E>::emit(E e) const
                          ^
/usr/local/include/Wt/WSignal.h: In member function ‘void Wt::EventSignal<E>::processDynamic(const Wt::JavaScriptEvent&) const’:
/usr/local/include/Wt/WSignal.h:919:16: error: expected unqualified-id before ‘(’ token
   dynamic_.emit(event);
                ^
In file included from /usr/local/include/Wt/WWidget.h:15:0,
                 from /usr/local/include/Wt/WWebWidget.h:14,
                 from /usr/local/include/Wt/WInteractWidget.h:10,
                 from /usr/local/include/Wt/WContainerWidget.h:10,
                 from main/helperfunctions.h:43,
                 from main/helperfunctions.cpp:18:
/usr/local/include/Wt/WJavaScript.h: At global scope:
/usr/local/include/Wt/WJavaScript.h:297:14: error: expected ‘)’ before ‘...’ token
   void emit(A... args) const;
              ^~~
/usr/local/include/Wt/WJavaScript.h:503:25: error: expected unqualified-id before ‘(’ token
 void JSignal<A...>::emit(A... args) const
                         ^
/usr/local/include/Wt/WJavaScript.h: In member function ‘void Wt::JSignal<A>::operator()(A ...) const’:
/usr/local/include/Wt/WJavaScript.h:511:15: error: expected binary operator before ‘)’ token
   emit(args...);
               ^
/usr/local/include/Wt/WJavaScript.h: In member function ‘void Wt::Impl::Holder<A>::doEmit(Wt::Impl::seq<S ...>)’:
/usr/local/include/Wt/WJavaScript.h:596:16: error: expected unqualified-id before ‘(’ token
     signal.emit(std::get<S>(args)...);
                ^
main/helperfunctions.cpp: In function ‘void SetIconColor(QString, QIcon&, QString)’:
main/helperfunctions.cpp:468:59: warning: unused parameter ‘svgcolor’ [-Wunused-parameter]
 void SetIconColor(QString svgres, QIcon &svgicon, QString svgcolor)
                                                           ^~~~~~~~
main/helperfunctions.cpp: In function ‘QStringList FindWtLibFiles(QString, QStringList)’:
main/helperfunctions.cpp:1050:22: warning: unknown escape sequence: '\w'
   strRegex = QString("(\w)*%1(.)*[^(%2)\s]+(%2)").arg(listOfLibNames.at(i)).arg(strExtensions);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
main/helperfunctions.cpp:1050:22: warning: unknown escape sequence: '\s'
main/helperfunctions.cpp: In function ‘void PrintAllConnections(SignalEmiter*, QByteArray&)’:
main/helperfunctions.cpp:296:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
    config += "\t\t" + rootobj->m_listConnections.at(i)->m_strsender    + "->"
    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  + rootobj->m_listConnections.at(i)->m_strsignal    + "().connect(std::bind([=]() { "
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  + rootobj->m_listConnections.at(i)->m_strreceiver  + "->"
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  + rootobj->m_listConnections.at(i)->m_strslot      + " (\""
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  + rootobj->m_listConnections.at(i)->m_strparameter + "\"); }));\n";
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main/helperfunctions.cpp:301:3: note: here
   case WtQtWidget::Wt_Slots_toggleStyleClass:
   ^~~~
Makefile:787: recipe for target 'helperfunctions.o' failed
make: *** [helperfunctions.o] Error 1

ppetraki avatar Jun 02 '20 15:06 ppetraki

Hi,

Sadly, this project is unmantained since I do not have time to invest in it due to work and children. But looking at your errors, it seems the issue is when compiling the Wt code, specially in Wt/Signals/signals.hpp, the token ... points to be related to variadic templates.

First thing I would check is what is the minimum C++ version (c+11 or c++17) that Wt required and check that your GCC version matches that version of the C++ standard. In my experience, most errors while compling templates come from not happing a compiler that supports what I am trying to do.

juangburgos avatar Jun 03 '20 12:06 juangburgos

Hello,

I understand the nature of opensource, I used to work for Canonical. There's no need to apologize. I'm grateful for the contributions you have already made! Do you know of anyone else who is most active in keeping this tool alive? I don't want to go off and reinvent the wheel.

Those youtube videos are great btw! It really helped this old systems guy get a better handle on using Wt.

Concerning the bug. I'm on 18.04 with the latest gcc so the default std is at least 14.

g++ -dM -E -x c++  /dev/null | grep -F __cplusplus
#define __cplusplus 201402L

I reduced the issue down to a minimal case and strangely enough it appears to be the order in which the include files are added.

This is the failing case:

#include <QObject>
#include <Wt/WContainerWidget.h>

Wt::WContainerWidget * GetWContainerParent(QObject *qparent);

compiled like so

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o run-cru foo.cpp

If I swap the headers, making qobject the last thing included, it compiles fine.

I managed to get a lot further with the build using this hack but eventually it caught up to me again.

I'm guessing there must be some macro shadowing going on which is turning that perfectly fine template code into garbage. I'll dive into the include tree further to see how close I need to get to the signal classes before it breaks. It is an issue Wt will need to address or at least needs to be brought to their attention. Thanks.

ppetraki avatar Jun 03 '20 13:06 ppetraki

Wt issue opened.

https://redmine.webtoolkit.eu/issues/7591

ppetraki avatar Jun 03 '20 14:06 ppetraki

So my instincts were right about the define. https://redmine.webtoolkit.eu/issues/7591#note-3

Adding CONFIG += no_keywords to the pro file did the trick.

Let the porting continue! :-)

ppetraki avatar Jun 05 '20 13:06 ppetraki

But that was already considered in WtDesigner qmake project:

Are you not using the existing project to build?

juangburgos avatar Jun 05 '20 14:06 juangburgos

The original project file had so much stuff from boost back from when Wt depended on it that I just blew it away and made qmake generate a new one for me. I couldn't even begin figuring out what the compilation errors were until I got all the library dependency errors out of the way. I'll grab the rest of the defs.

Thank you for pointing that out. I know even less about Qt than I do of Wt.

ppetraki avatar Jun 05 '20 15:06 ppetraki

Do you have any idea where ui_mainwindow.h went? It's not anywhere in the history and it's being used here.

In file included from main/mainpage.cpp:22:0: main/mainwindow.h:76:6: error: ‘MainWindow’ in namespace ‘Ui’ does not name a type Ui::MainWindow ui; ^~~~~~~~~~

It was included in that cpp file so it built at one point.

ppetraki avatar Jun 06 '20 17:06 ppetraki

You should build using qmake. There are a lot of files generated by qt's moc compiler. You should really look on google on how to build qt projects.

juangburgos avatar Jun 06 '20 17:06 juangburgos