Travis CI QT not building - c++

So I wanted to use travis for this project today. Sadly it failed with this error:
$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o downloadmanager.o downloadmanager.cpp
In file included from downloadmanager.h:11:0,
from downloadmanager.cpp:1:
mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
compilation terminated.
make: *** [downloadmanager.o] Error 1
The command "make" exited with 2.
Here is the full log.
Note I first had problems with it not recognizing the Network module file (e.g. QNetworkAccessManager). I fixed this by executing QMake with "QT += network". Now it cannot find the GUI files (e.g. QMessageBox) but adding "QT += network gui" did not do the trick.

You need to add widgets to get classes such as QMessageBox and QMainWindow:
QT += widgets network gui
For future reference, please consult the Qt 5 documentation. The page for each class indicates what must be added to your qmake for that class (right at the top of the page). See, for example, the page for QMessageBox.

Related

QT 5.x compilation of Windows software on Linux

I'm trying to compile windows software on linux with qt but each time I try to compile I get the following error:
i686-w64-mingw32.static-g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I/mxe/usr/i686-w64-mingw32.static/qt5/include -I/mxe/usr/i686-w64-mingw32.static/qt5/include/QtSvg -I/mxe/usr/i686-w64-mingw32.static/qt5/include/QtWidgets -I/mxe/usr/i686-w64-mingw32.static/qt5/include/QtGui -I/mxe/usr/i686-w64-mingw32.static/qt5/include/QtNetwork -I/mxe/usr/i686-w64-mingw32.static/qt5/include/QtCore -Irelease -I. -I/mxe/usr/i686-w64-mingw32.static/qt5/mkspecs/win32-g++ -o release/inventoryview.o View/inventoryview.cpp
In file included from View/inventoryview.cpp:2:0:
./ui_inventoryview.h:21:50: fatal error: Widget\Inventory\inventoryplusbutton.h: No such file or directory
compilation terminated.
Makefile.Release:6009: recipe for target 'release/inventoryview.o' failed
make[1]: Leaving directory '/builds/Skytwoo/qt-test/Synaps-Software'
make[1]: * [release/inventoryview.o] Error 1
Makefile:36: recipe for target 'release' failed
make: * [release] Error 2
I check multiple times and every folder exists.
Everything is run on Ubuntu inside a docker container with this command.
make -f Makefile.Release
As BoBTFish said, you can't have \ (backslashes) in your path. What you have to do here is to change Widget\Inventory\inventoryplusbutton.h into Widget/Inventory/inventoryplusbutton.h and make sure it exists.

Building SWipe Application

I'm currently trying to build this application https://github.com/ieatlint/SWipe on macOS and am not having any luck. I don't know much about building applications but this is what I have done so far.
git clone https://github.com/ieatlint/SWipe
cd SWipe
qmake SWipe.pro
make
And that's where I get an error:
make
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/local/Cellar/qt/5.9.1/lib/QtMultimedia.framework/Headers -I/usr/local/Cellar/qt/5.9.1/lib/QtWidgets.framework/Headers -I/usr/local/Cellar/qt/5.9.1/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt/5.9.1/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt/5.9.1/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt/5.9.1/mkspecs/macx-clang -F/usr/local/Cellar/qt/5.9.1/lib -o main.o main.cpp
main.cpp:1:10: fatal error: 'QtGui/QApplication' file not found
#include <QtGui/QApplication>
^
1 error generated.
make: *** [main.o] Error 1
I tried adding QT += widgets to the SWipe.pro file by using sudo nano SWipe.pro and adding it under where it says QT += core gui multimedia, but that didn't work.
I just cloned it quickly and had a look. Here is what's wrong with the code:
add widgets to the pro file as you already did (run qmake after this again)
in main.cpp change the include from QtGui/QApplication to just Application (as suggested by AlexanderVX)
Do the same in swipe.h for QtGui/QMainWindow and change it to just QMainWindow
in swipe.cpp change audioFormat.setFrequency( 48000 ) to audioFormat.setSampleRate( 48000 ), assuming that is what it should do as there is no setFrequency function
in swipe.cpp change audioFormat.setChannels( 1 ) to audioFormat.setChannelCount( 1 ), assuming that is what it should do as there is no setChannels function
I did this on my Mac and it builds this way. Have not run it though as I have not really looked into what this thing is doing... that's your job now I guess

qmake with Jenkins

I am trying to make Jenkins do the compile and build for me whenever I push commit to Git. I have a helloworld app created in Qt Creator. It does compile and build in Qt Creator, it does show on my phone, but it doesn't want to compile and build with Jenkins.
I am using the same shell commands which QtC used:
qmake helloworld.pro -r -spec android-g++;
make;
The console output is:
+ qmake helloworld.pro -r -spec android-g++
+ make
/home/ndk/toolchains/arm-linux-androideabi-4.9-/prebuilt/bin/arm-linux-androideabi-g++ -c -pipe -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -I/usr/share/qt4/mkspecs/android-g++ -I. -I. -I/home/ndk/sources/cxx-stl/gnu-libstdc++//include -I/home/ndk/sources/cxx-stl/gnu-libstdc++//libs//include -I/home/ndk/platforms//arch-arm//usr/include -o main.o main.cpp
In file included from main.cpp:1:0:
mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
#include <QMainWindow>
^
compilation terminated.
Makefile:187: recipe for target 'main.o' failed
make: *** [main.o] Error 1
My helloworld.pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworld
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY =
main.cpp
#include "mainwindow.h"
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
EDIT/UPDATE:
So far, I have tried to specify the full path to qmake, to be sure that I use Qt's qmake.
/home/qt/5.7/android_armv7/bin/qmake helloworld.pro -r -spec android-g++;
make;
The output is:
/home/qt/5.7/android_armv7/bin/uic mainwindow.ui -o ui_mainwindow.h
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o main.o main.cpp
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o mainwindow.o mainwindow.cpp
mainwindow.cpp:3:25: fatal error: QtGui/QAction: No such file or directory
#include <QtGui/QAction>
^
compilation terminated.
Makefile:1780: recipe for target 'mainwindow.o' failed
make: *** [mainwindow.o] Error 1
Most likely your jenkins setup uses the wrong qmake. There's a 1:1 mapping between a Qt installation and its qmake. So, your install of Qt for android will have its own qmake that you must refer to by full path! Qt Creator sets up the path so that this happens automatically, Jenkins doesn't - and it shouldn't anyway.
When building for any particular Qt version, you only need to invoke its qmake explicitly. From then onwards, as long as the proper compiler is in the path, things will happen as they should and you don't ever need to refer to that Qt version manually again. The makefiles will all refer to Qt libraries, headers and tools from that Qt install.
You also don't need the -spec argument. Each Qt installation is compiled for a particular mkspec, so qmake itself knows exactly what the spec is. I have no idea why QtCreator gives that argument, it doesn't make much sense.
The only Qt header path that's in your commandline is the one for the mkspec. I would blame the server's Qt installation for this.
Ensure Qt for Android is properly installed on the server, and that it is its qmake you are calling.

shaders' plugin installation in QML

I want to try using QML ShaderEffectItem on QGraphicsView
I have cloned files from https://qt.gitorious.org/qt-labs/qml1-shadersplugin how is written in post, and i have compiled this plugin in ~/Dev/GitRepo/qml1-shadersplugin$:
using QtCreator, compiles this file: qmlshadersplugin.pro
But now i run in this folder(~/Dev/GitRepo/qml1-shadersplugin): make install
And i have many: errors:
~/Dev/GitRepo/qml1-shadersplugin$ make installcd src/ && make -f Makefile install
make[1]: Entering directory `/home/goran/Dev/GitRepo/qml1-shadersplugin/src'
g++ -c -m32 -pipe -O2 -D_REENTRANT -Wall -W -fPIC -DQT_NO_DEBUG -DQT_PLUGIN -DQT_DECLARATIVE_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++-32 -I. -I../../../../QtSDK/Desktop/Qt/474/gcc/include/QtCore -I../../../../QtSDK/Desktop/Qt/474/gcc/include/QtGui -I../../../../QtSDK/Desktop/Qt/474/gcc/include/QtOpenGL -I../../../../QtSDK/Desktop/Qt/474/gcc/include/QtDeclarative -I../../../../QtSDK/Desktop/Qt/474/gcc/include -I/usr/X11R6/include -I. -o qmlshadersplugin_plugin.o qmlshadersplugin_plugin.cpp
In file included from ../../../../QtSDK/Desktop/Qt/474/gcc/include/QtOpenGL/QtOpenGL:5:0,
from shadereffectitem.h:46,
from qmlshadersplugin_plugin.cpp:43:
../../../../QtSDK/Desktop/Qt/474/gcc/include/QtOpenGL/qgl.h:77:20: fatal error: GL/gl.h: No such file or directory
compilation terminated.
make[1]: *** [qmlshadersplugin_plugin.o] Error 1
make[1]: Leaving directory `/home/igor/Dev/GitRepo/qml1-shadersplugin/src'
make: *** [sub-src-install_subtargets] Error 2
What's the problem ?
GL/gl.h: No such file or directory
This means that you either do not have opengl library installed (very unlikely), or you didn't enabled it in your qmake file (very likely). To enable opengl in the qmake file, you need to add this line :
QT += opengl
More about it here.

Problem building stripped down version of Qt 4.6.2

I'm trying to build a smaller version of Qt, I used the following configuration options:
./configure -qt-sql-mysql -no-qt3support -no-audio-backend -no-phonon -no-phonon-backend -no-opengl -no-script -no-scripttools -no-javascript-jit -no-webkit -no-svg -no-multimedia -fast
After executing make, I eventually run into the following error:
make[3]: Entering directory `/opt/qtsdk-2010.02/qt/tools/assistant/tools'
cd assistant/ && make -f Makefile
make[4]: Entering directory `/opt/qtsdk-2010.02/qt/tools/assistant/tools/assistant'
g++ -c -pipe -g -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB
-DQT_NETWORK_LIB -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_SHARED
-I../../../../mkspecs/linux-g++ -I. -I../../../../include/QtCore
-I../../../../include/QtNetwork -I../../../../include/QtGui -I../../../../include/QtXml
-I../../../../include/QtSql -I../../../../include -I../../../../include/QtHelp
-I../../../shared/fontpanel -I.moc/release-shared -I.uic/release-shared
-o .obj/release-shared/helpviewer.o helpviewer.cpp
In file included from helpviewer.cpp:42:
helpviewer.h:51:20: error: QWebView: No such file or directory
Any pointers on what is wrong here?
It is trying to build the Assistant (that is the tool you us to view Qt documentation) tool, the Assistant needs webkit. If you don't need Assistant in your application when you are distributing it, just exclude it from the build