Author Topic: Compile error  (Read 1409 times)

krege

  • Newbie
  • *
  • Posts: 10
Compile error
« on: January 18, 2017, 11:39:01 AM »
Hi,

I tried to compile ovito from sources on my Fedora 25 machine and faced some issues I can't resolve (at least  in a couple of days I tried to dig into it).
Here is the log:
Code: [Select]
[ 45%] Building CXX object src/gui/CMakeFiles/Gui.dir/Gui_automoc.cpp.o
cd /home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui && /usr/bin/c++   -DFLOATTYPE_FLOAT -DGui_EXPORTS -DOVITO_VIDEO_OUTPUT_SUPPORT -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui -I/home/kryzhev/Distr/ovito/ovito-git-tebuild/src/gui -I/home/kryzhev/Distr/ovito/ovito-git-tebuild/src -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/./mkspecs/linux-g++ -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtConcurrent -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtNetwork  -fPIC   -fPIC -std=gnu++11 -o CMakeFiles/Gui.dir/Gui_automoc.cpp.o -c /home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/Gui_automoc.cpp
In file included from /home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/Gui_automoc.cpp:64:0:
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportMenu.cpp: In static member function 'static void Ovito::ViewportMenu::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportMenu.cpp:108:21: error: 'class Ovito::ViewportMenu' has no member named 'onWindowFocusChanged'; did you mean 'windowIconChanged'?
         case 8: _t->onWindowFocusChanged(); break;
                     ^~~~~~~~~~~~~~~~~~~~
In file included from /home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/Gui_automoc.cpp:65:0:
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportWindow.cpp: In member function 'virtual void* Ovito::ViewportWindow::qt_metacast(const char*)':
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportWindow.cpp:81:40: error: cannot call member function 'virtual void* QWindow::qt_metacast(const char*)' without object
     return QWindow::qt_metacast(_clname);
                                        ^
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportWindow.cpp: In member function 'virtual int Ovito::ViewportWindow::qt_metacall(QMetaObject::Call, int, void**)':
/home/kryzhev/Distr/ovito/ovito-git-tebuild/testbuild/src/gui/moc_ViewportWindow.cpp:86:43: error: cannot call member function 'virtual int QWindow::qt_metacall(QMetaObject::Call, int, void**)' without object
     _id = QWindow::qt_metacall(_c, _id, _a);
                                           ^
src/gui/CMakeFiles/Gui.dir/build.make:2443: recipe for target 'src/gui/CMakeFiles/Gui.dir/Gui_automoc.cpp.o' failed
make[2]: *** [src/gui/CMakeFiles/Gui.dir/Gui_automoc.cpp.o] Error 1

Did I missed anything?
Questions welcomed.

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 555
Re: Compile error
« Reply #1 on: January 18, 2017, 12:16:32 PM »
Hi,

I'm not familiar with Fedora Linux, but I assume Fedora 25 is rather old and may come with an old version of the Qt library. My hypothesis is that you are building Ovito against Qt 5.2 or 5.3. That is something I haven't tested for some time now (current version of Qt is 5.8 ). So perhaps the error is due to an undiscovered backward incompatibility. It could be that the MOC compiler of Qt 5.2/5.3 cannot handle the #if directive found in line 53 of src/gui/viewport/ViewportMenu.h. Try to comment out this line (and the corresponding #endif) to work around the issue:

Code: [Select]
// #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
void onWindowFocusChanged() {
if(QGuiApplication::focusWindow() && QGuiApplication::focusWindow()->flags().testFlag(Qt::Popup) == false) {
hide();
}
}
// #endif

krege

  • Newbie
  • *
  • Posts: 10
Re: Compile error
« Reply #2 on: January 19, 2017, 03:21:22 AM »
Fedora runs Qt 5.7.1 currently. I suppose it's not too old.

Well. It would not fix everything in a long term. But you point me the way. Those lines do not have to be commented. I added QtGlobal header which is not auto-included by my 6.3.1 gcc and first error disappeared.
There were two more error as seen in #1 but they resolved in a same way (with src/gui/viewport/ViewportWindow.h). Now it all works.

Thanks!

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 555
Re: Compile error
« Reply #3 on: January 19, 2017, 08:50:36 AM »
Okay, great that you found out what caused this error. I now added <QtGlobal> to the list of headers that are included in every source file (https://gitlab.com/stuko/ovito/commit/8d57d2093c1ecc5301797e253273092c7ce95596).

krege

  • Newbie
  • *
  • Posts: 10
Re: Compile error
« Reply #4 on: January 19, 2017, 11:41:17 AM »
Sorry, that not works. Gcc 6 requires explicit declaration of headers. If you use some macros from QtGlobal it must be listed in headers. So it should be mentioned both in src/gui/viewport/ViewportMenu.h and src/gui/viewport/ViewportWindow.h to prevent this error to appear.

(It's not hard for me to add it by hand every time I pull sources if there are any issues related)

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 555
Re: Compile error
« Reply #5 on: January 19, 2017, 12:32:25 PM »
Sorry, I'm not sure if I understand.

After my change, ViewportMenu.h now includes <gui/GUI.h>, which includes <core/Core.h>, which includes <QtGlobal>. Why does GCC 6 still not see the macros defined in <QtGlobal>?

If you can, and if you find that my solution is insufficient please open an issue or a merge request on GitLab:

https://gitlab.com/stuko/ovito

Thanks.

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 555
Re: Compile error
« Reply #6 on: February 17, 2017, 03:02:29 PM »
It looks like there is another user facing the same issue described in this forum thread. He created an issue on GitLab:

https://gitlab.com/stuko/ovito/issues/14

@krege: Can you please describe your solution. Which changes to the source code did you exactly make to fix the compilation error?

Thanks.