pentix / qjournalctl

A multi-platform, Qt-based frontend for systemd's journalctl command. Accepting local as well as remote (SSH) data sources.
GNU General Public License v3.0
166 stars 17 forks source link

Unable to compile v.0.3, v.0.4 and git master on Ubuntu Xenial Xerus (16.04 LTS) #10

Closed N0rbert closed 6 years ago

N0rbert commented 6 years ago

I have installed all needed dependencies:

sudo apt-get install qt5-default cmake gcc g++ build-essential git

Cloned your repository and started compilation

git clone https://github.com/pentix/qjournalctl.git
cd qjournalctl
./autogen.sh
make

and got the following error:

xenial@xenial-vb:~/Downloads/qjournalctl$ make
/usr/lib/x86_64-linux-gnu/qt5/bin/uic ui/mainwindow.ui -o ui_mainwindow.h
/usr/lib/x86_64-linux-gnu/qt5/bin/uic ui/aboutdialog.ui -o ui_aboutdialog.h
/usr/lib/x86_64-linux-gnu/qt5/bin/uic ui/showbootlog.ui -o ui_showbootlog.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o src/main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o mainwindow.o src/mainwindow.cpp
src/mainwindow.cpp:61:3: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
   message_box.critical(nullptr, "Error", "No boots have been found :\n"+process.readAllStandardError());
   ^
In file included from src/mainwindow.cpp:12:0:
src/showbootlog.h:53:17: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  bool sinceFlag=false, untilFlag=false;
                 ^
src/showbootlog.h:53:34: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  bool sinceFlag=false, untilFlag=false;
                                  ^
src/showbootlog.h:54:23: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  bool completeJournal=false;
                       ^
src/showbootlog.h:55:16: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  bool realtime=false;
                ^
src/showbootlog.h:56:15: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  bool reverse=false;
               ^
src/showbootlog.h:57:18: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  int maxPriority=3;
                  ^
src/showbootlog.h:58:24: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  int numberOfBytesRead=0;
                        ^
src/showbootlog.h:59:26: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  QString identifierFlags="";
                          ^
src/mainwindow.cpp: In member function ‘void MainWindow::on_listBootsButton_clicked()’:
src/mainwindow.cpp:61:24: error: ‘nullptr’ was not declared in this scope
   message_box.critical(nullptr, "Error", "No boots have been found :\n"+process.readAllStandardError());
                        ^
src/mainwindow.cpp: At global scope:
src/mainwindow.cpp:141:64: warning: unused parameter ‘index’ [-Wunused-parameter]
 void MainWindow::on_tableView_doubleClicked(const QModelIndex &index)
                                                                ^
src/mainwindow.cpp:172:58: warning: unused parameter ‘index’ [-Wunused-parameter]
 void MainWindow::on_tableView_clicked(const QModelIndex &index)
                                                          ^
Makefile:371: recipe for target 'mainwindow.o' failed
make: *** [mainwindow.o] Error 1

So your great program does not compile on LTS Ubuntu version. Only previous v.0.21 version compiles normally on Ubuntu. IMHO creating software only for bleeding-edge Arch is not good idea.

Note: first seen on AskUbuntu.

pentix commented 6 years ago

Hi, thank you very much for pinging me on this issue! Also thanks for helping out the other user in the AskUbuntu forum!

At the first sight it seems as if g++ does not automatically compile for C++11 (that's why it suggests to use the -std=c++11. Also the variable nullptr is defined when using the C++11 standard.

As a first workaround, you could execute ./autogen.sh and then edit the Makefile. On approximately line 17 you should see something like

CXXFLAGS      = -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -W -D_REENTRANT -fPIC $(DEFINES)

Add the flag there

CXXFLAGS      = -std=c++11 -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -W -D_REENTRANT -fPIC $(DEFINES)

Then try again, running

make clean
make

I totally agree that it should not only run on bleeding-edge systems but Ubuntu just sometimes really takes years to update the software in their repositories, because compiling for C++11 should (in my opinion) not require any flag anymore (at least now, that C++14 and C++17 are already more or less published and used...) and gcc also already changed this some years ago.

BTW: I also found this (https://stackoverflow.com/a/44735016/2628569) code snippet to show you the default C++ version your compiler compiles.

I see that this is an issue and as soon as I find time I will add this as a default option so you won't have to edit the Makefile manually anymore. ☺️

Please tell me if the given workaround works for you! Thanks again!

dopsi commented 6 years ago

Hi @pentix,

What about adding the CONFIG += c++11 [1] to the qjournalctl.pro file ?

pentix commented 6 years ago

@dopsi Thanks for this, I didn't quite have the time to look it up but this seems like the most reasonable to do. In my environment this adds -std=gnu++11 to the Makefile.

@N0rbert Could you try to do

git pull make clean ./autogen.sh make

I hope by adding what @dopsi mentioned, it should compile now! 😄

Edit: I already plan some more stuff to be implemented soon (1 week, post-examination phase 😅), and I'm a bit short of time, that's why I did not increase and publish a new version for now. But compiling the master branch should work now :)

N0rbert commented 6 years ago

Thank you for fast response and fix! I cloned master again, it compiles and runs on Ubuntu 14.04 LTS, 16.04 LTS and 18.04 LTS without any user intervention.