Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile on Ubuntu 22.04 because of some deprecation warnings which are treated as errors #220

Open
swiss-knight opened this issue Mar 15, 2023 · 1 comment

Comments

@swiss-knight
Copy link

swiss-knight commented Mar 15, 2023

Hello,

I'm following the official documentation available here to compile MicMac on Ubuntu 22.04.2 LTS.

First thing: qt5-default doesn't exist anymore:

$ sudo apt-get install make imagemagick libimage-exiftool-perl exiv2 proj-bin qt5-default cmake build-essential

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package qt5-default is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'qt5-default' has no installation candidate

So when trying to build, it quickly stops:

$ cmake -DWITH_QT5=1 -DWITH_CPP11=1 ..
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- -----> OpenGL found
CMake Error at CMakeLists.txt:211 (find_package):
  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt5Widgets", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5Widgets" with
  any of the following names:

    Qt5WidgetsConfig.cmake
    qt5widgets-config.cmake

  Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
  "Qt5Widgets_DIR" to a directory containing one of the above files.  If
  "Qt5Widgets" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!
See also "/opt/micmac/build/CMakeFiles/CMakeOutput.log".

But installing those packages as described here, fixed the issue.
The compilation goes well, until the very where this error occurs:

/opt/micmac/src/util/visual_mainwindow.cpp: In member function ‘virtual void visual_MainWindow::resizeEvent(QResizeEvent*)’:
/opt/micmac/src/util/visual_mainwindow.cpp:992:56: error: ‘int QDesktopWidget::screenNumber(const QPoint&) const’ is deprecated: Use QGuiApplication::screenAt() [-Werror=deprecated-declarations]
  992 |     QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
      |                                         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /opt/micmac/src/saisieQT/include_QT/Elise_QT.h:40,
                 from /opt/micmac/src/saisieQT/include_QT/saisieQT_window.h:4,
                 from /opt/micmac/include/general/visual_mainwindow.h:9,
                 from /opt/micmac/src/util/visual_mainwindow.cpp:4:
/usr/include/x86_64-linux-gnu/qt5/QtWidgets/qdesktopwidget.h:75:60: note: declared here
   75 |     QT_DEPRECATED_X("Use QGuiApplication::screenAt()") int screenNumber(const QPoint &) const;
      |                                                            ^~~~~~~~~~~~
/opt/micmac/src/util/visual_mainwindow.cpp:992:40: error: ‘const QRect QDesktopWidget::screenGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Werror=deprecated-declarations]
  992 |     QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
      |                       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/micmac/src/saisieQT/include_QT/Elise_QT.h:40,
                 from /opt/micmac/src/saisieQT/include_QT/saisieQT_window.h:4,
                 from /opt/micmac/include/general/visual_mainwindow.h:9,
                 from /opt/micmac/src/util/visual_mainwindow.cpp:4:
/usr/include/x86_64-linux-gnu/qt5/QtWidgets/qdesktopwidget.h:79:67: note: declared here
   79 |     QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect screenGeometry(int screen = -1) const;
      |                                                                   ^~~~~~~~~~~~~~

cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/elise.dir/build.make:11229: src/CMakeFiles/elise.dir/util/visual_mainwindow.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:400: src/CMakeFiles/elise.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Could you provide a fix or any hint on how to solve this issue?
The errors seems to originate from here:

void visual_MainWindow::resizeEvent(QResizeEvent *)
{
QDesktopWidget* m = qApp->desktop();
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
int desk_x = desk_rect.width();
int desk_y = desk_rect.height();
move(desk_x / 2 - width() / 2 + desk_rect.left(), desk_y / 2 - height() / 2 + desk_rect.top());
}

Thanks a lot.

Warm Regards.

@phidelity28
Copy link

phidelity28 commented Oct 6, 2023

I solved the QT-default issue with the following edits to the standard installation :

remove the qt-5 from the bulk install call
$ sudo apt-get install make imagemagick libimage-exiftool-perl exiv2 proj-bin cmake build-essential

workaround for the qt-5 not wokring

I found this helpful explanation

then installed the qt packages separately
$ sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-toolscd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants