Flameshot: Compilation failing on Ubuntu 16.04.4

Created on 23 Apr 2018  Â·  8Comments  Â·  Source: flameshot-org/flameshot

Trying to compile the today version (c942383b0086a39758d12ca549ffb624bedb8492).
GCC is gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

This is the error message:

src/widgets/capture/buttonhandler.cpp: In member function ‘QRect ButtonHandler::intersectWithAreas(const QRect&)’:
src/widgets/capture/buttonhandler.cpp:224:26: error: ‘begin’ was not declared in this scope
     for(const QRect &r : m_screenRegions) {
                          ^
src/widgets/capture/buttonhandler.cpp:224:26: note: suggested alternative:
In file included from /usr/include/c++/5/string:51:0,
                 from /usr/include/c++/5/random:40,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:85,
                 from /usr/include/x86_64-linux-gnu/qt5/QtGui/qicon.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qabstractbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qpushbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QPushButton:1,
                 from src/widgets/capture/capturebutton.h:20,
                 from src/widgets/capture/buttonhandler.h:20,
                 from src/widgets/capture/buttonhandler.cpp:18:
/usr/include/c++/5/bits/range_access.h:87:5: note:   ‘std::begin’
     begin(_Tp (&__arr)[_Nm])
     ^
src/widgets/capture/buttonhandler.cpp:224:26: error: ‘end’ was not declared in this scope
     for(const QRect &r : m_screenRegions) {
                          ^
src/widgets/capture/buttonhandler.cpp:224:26: note: suggested alternative:
In file included from /usr/include/c++/5/string:51:0,
                 from /usr/include/c++/5/random:40,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:85,
                 from /usr/include/x86_64-linux-gnu/qt5/QtGui/qicon.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qabstractbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qpushbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QPushButton:1,
                 from src/widgets/capture/capturebutton.h:20,
                 from src/widgets/capture/buttonhandler.h:20,
                 from src/widgets/capture/buttonhandler.cpp:18:
/usr/include/c++/5/bits/range_access.h:97:5: note:   ‘std::end’
     end(_Tp (&__arr)[_Nm])
     ^
Makefile:1132: recipe for target 'buttonhandler.o' failed
make: *** [buttonhandler.o] Error 1

Thanks!

All 8 comments

@Rmano It's because of the Qt version, QVector doesn't implement standard C++ iterators in that version. You can try update Qt version to 5.8.0+.

By the way, The author of flameshot said,

the fix is easy, that loop has to be replaced with a conventional loop or QT's foreach

I'm fixing it today.

It should be fixed now. The problem was the lack of implementation of iterators for the QRegion class.
That feature was introduced with QT 5.8

Perfect, thanks a lot.

I'm still seeing this on latest master, was this ever fixed?

I'm on Ubuntu 16.04

cd /tmp
git clone https://github.com/flameshot-org/flameshot.git && cd flameshot
mkdir build && cd build
sudo apt update
sudo apt install g++ cmake build-essential qt5-default qttools5-dev-tools libqt5svg5-dev libqt5dbus5 libqt5network5 libqt5core5a libqt5widgets5 libqt5gui5 libqt5svg5 git openssl ca-certificates  # deps from readme
cmake ..
make -j

But I get

...
[ 97%] Building CXX object src/CMakeFiles/flameshot.dir/__/external/Qt-Color-Widgets/src/color_utils.cpp.o
[ 98%] Building CXX object src/CMakeFiles/flameshot.dir/tools/circle/circletool.cpp.o
[ 99%] Building CXX object src/CMakeFiles/flameshot.dir/flameshot_autogen/IJ3KGTTQ5V/qrc_graphics.cpp.o
/tmp/flameshot/src/widgets/capture/buttonhandler.cpp: In member function ‘QRect ButtonHandler::intersectWithAreas(const QRect&)’:
/tmp/flameshot/src/widgets/capture/buttonhandler.cpp:246:25: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
  246 |   for (const QRect& r : m_screenRegions) {
      |                         ^~~~~~~~~~~~~~~
      |                         std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/stdexcept:39,
                 from /usr/include/c++/9/array:39,
                 from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:85,
                 from /usr/include/x86_64-linux-gnu/qt5/QtGui/qicon.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qabstractbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qpushbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QPushButton:1,
                 from /tmp/flameshot/src/widgets/capture/capturebutton.h:20,
                 from /tmp/flameshot/src/widgets/capture/capturetoolbutton.h:20,
                 from /tmp/flameshot/src/widgets/capture/buttonhandler.h:20,
                 from /tmp/flameshot/src/widgets/capture/buttonhandler.cpp:18:
/usr/include/c++/9/bits/range_access.h:105:37: note: ‘std::begin’ declared here
  105 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
      |                                     ^~~~~
/tmp/flameshot/src/widgets/capture/buttonhandler.cpp:246:25: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
  246 |   for (const QRect& r : m_screenRegions) {
      |                         ^~~~~~~~~~~~~~~
      |                         std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/stdexcept:39,
                 from /usr/include/c++/9/array:39,
                 from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:85,
                 from /usr/include/x86_64-linux-gnu/qt5/QtGui/qicon.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qabstractbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qpushbutton.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QPushButton:1,
                 from /tmp/flameshot/src/widgets/capture/capturebutton.h:20,
                 from /tmp/flameshot/src/widgets/capture/capturetoolbutton.h:20,
                 from /tmp/flameshot/src/widgets/capture/buttonhandler.h:20,
                 from /tmp/flameshot/src/widgets/capture/buttonhandler.cpp:18:
/usr/include/c++/9/bits/range_access.h:107:37: note: ‘std::end’ declared here
  107 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
      |                                     ^~~
src/CMakeFiles/flameshot.dir/build.make:622: recipe for target 'src/CMakeFiles/flameshot.dir/widgets/capture/buttonhandler.cpp.o' failed
make[2]: *** [src/CMakeFiles/flameshot.dir/widgets/capture/buttonhandler.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/tmp/flameshot/src/widgets/orientablepushbutton.cpp: In member function ‘virtual void OrientablePushButton::paintEvent(QPaintEvent*)’:
/tmp/flameshot/src/widgets/orientablepushbutton.cpp:64:31: error: ‘class QRect’ has no member named ‘transposed’; did you mean ‘translated’?
   64 |     option.rect = option.rect.transposed();
      |                               ^~~~~~~~~~
      |                               translated
/tmp/flameshot/src/widgets/orientablepushbutton.cpp:70:31: error: ‘class QRect’ has no member named ‘transposed’; did you mean ‘translated’?
   70 |     option.rect = option.rect.transposed();
      |                               ^~~~~~~~~~
      |                               translated
src/CMakeFiles/flameshot.dir/build.make:817: recipe for target 'src/CMakeFiles/flameshot.dir/widgets/orientablepushbutton.cpp.o' failed
make[2]: *** [src/CMakeFiles/flameshot.dir/widgets/orientablepushbutton.cpp.o] Error 1
CMakeFiles/Makefile2:277: recipe for target 'src/CMakeFiles/flameshot.dir/all' failed
make[1]: *** [src/CMakeFiles/flameshot.dir/all] Error 2
Makefile:170: recipe for target 'all' failed
make: *** [all] Error 2

Ubuntu 16's Qt5 is just too old, so it does not have the required features:

$ qmake --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu

We are not supporting ubuntu 16.04 since it is so close to end of life. I recommend upgrading.

Understandable, I'll forward that recommendation to my employer ;)

FYI if you are a user stuck on 16.04 we will be releasing an appimage and snap. It's just if you need to build from source there will be issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omkarnathsingh picture omkarnathsingh  Â·  4Comments

xstable picture xstable  Â·  3Comments

borgmanJeremy picture borgmanJeremy  Â·  3Comments

mrinvisible0 picture mrinvisible0  Â·  4Comments

szszoke picture szszoke  Â·  4Comments