I am trying to use Eclipse to build a Qt5 Widgets app on an Ubuntu 18.04 virtual machine. I'm able to create a Qt project file (.pro) with Eclipse. However, when I try to build it I get an error, "Build not configured correctly." I'd really appreciate any help resolving this. I've used the Eclipse CDT in other projects but this is the first time I've used it with a Qt project. I'd really like to continue using Eclipse for this project.
Details to reproduce follow:
I created a fresh Ubuntu 18.04.1 desktop install on a virtual machine by installing ubuntu-18.04.1-desktop-amd64.iso downloaded from http://releases.ubuntu.com/18.04/
Installed packages necessary to build Qt5 applications and the JRE to run eclipse.
sudo apt-get install qt5-default qtdeclarative5-dev qtquickcontrols2-5-dev
sudo apt-get install qml-module-qtquick-controls
sudo apt-get install g++ make
sudo apt-get install default-jre
Installed Eclipse CDT downloaded from http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/photon/R/eclipse-cpp-photon-R-linux-gtk-x86_64.tar.gz
Launched Eclipse and created a Qt project. In Eclipse I did File -> New -> C/C++Project. Then, I select "Qt C++/QML Application" template and clicked "Next". I set the project name to "hello" and clicked "Finish". I pressed Ctrl-B to build the project but the message, "Build not configured correctly" appeared in the CDT Build Console.
Next I verified that I did have all the build tools installed to build and run the application by building from the command line.
$ cd eclipse-workspace/hello/
$ qmake
Info: creating stash file /home/jdharper/eclipse-workspace/hello/.qmake.stash
$ make
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o hello.o hello.cpp
/usr/lib/qt5/bin/rcc -name hello hello.qrc -o qrc_hello.cpp
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qrc_hello.o qrc_hello.cpp
g++ -Wl,-O1 -o hello hello.o qrc_hello.o -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread
$ ./hello
At this point the application launched correctly.
Here's a screen shot of my Project > Properties.
Related
[MacOS Mojave 10.14.5, Xcode 10.2, ROS Kinetic, Qt 5.14.1]
I'm trying to build ROS Kinetic on my Macbook Pro. Certain modules within Kinetic utilise Qt, and I'm having a compilation problem because I have multiple versions of Qt on my system.
I have Qt v5.14.1, a Keg formula which is addressed(linked) through /usr/local/opt/qt, and Qt v4.8.7_6 which is addressed(linked) through /usr/local. I don't want to unlink/uninstall either.
The particular package I'm having difficulties with is qt_gui_cpp which uses CMakeLists.txt files. (Though the package is actually a catkin package, I haven't had any issues using CMake functionality in the make files.)
I'm using Apple's Clang++ compiler, and I think that, based on the types of errors being reported, the compiler is finding the wrong include folder even though the paths in the compiler's error messages is correct for the version I'm using, under the hood. I've tried using set(CMAKE_IGNORE_PATH /usr/local/include) but this hasn't helped.
The actual compiler command that is issued is below. Note that -I/usr/local/include precedes the Qt v5.14.1 include, thus the compiler only looks into the Qt v5.14.1 folder when it can't find it under /usr/local/include:
cd /Users/user/ros/ros_catkin_ws/build_isolated/qt_gui_cpp/src/qt_gui_cpp && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-DQT_CORE_LIB
-DQT_GUI_LIB
-DQT_NO_DEBUG
-DQT_WIDGETS_LIB
-DROS_BUILD_SHARED_LIBS=1
-DROS_PACKAGE_NAME=\"qt_gui_cpp\"
-Dqt_gui_cpp_EXPORTS
-I/Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/include
-I/Users/user/ros/ros_catkin_ws/install_isolated/include
-I/usr/local/include
-I/Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp/qt_gui_cpp
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtCore.framework/Headers
-isystem /usr/local/Cellar/python#2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/include/python2.7
-isystem /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/include/qt_gui_cpp
-isystem /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp
-iframework /usr/local/Cellar/qt/5.14.1/lib
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtWidgets.framework/Headers
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtGui.framework/Headers
-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers
-isystem /usr/local/Cellar/qt/5.14.1/./mkspecs/macx-clang
-I/usr/local/opt/qt/include
-L/usr/local/opt/qt/lib
-fPIC
-O3
-DNDEBUG
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-fPIC
-fPIC
-std=gnu++11
-o CMakeFiles/qt_gui_cpp.dir/composite_plugin_provider.cpp.o
-c /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp
How can I resolve this problem without breaking other things?
(More info if needed.)
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.
I'm working on porting an existing code from Qt4 to Qt5, and compilation works fine on 64 bits (the native system architecture), but fails with a strange error when I try to compile it to 32 bits:
$ QMAKESPEC=linux-g++-32 qmake-qt5
$ make
./create_version.sh
g++ -c -m32 -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DSLT -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -Iinclude -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -I/usr/lib64/qt5/mkspecs/linux-g++-32 -o main.o main.cpp
In file included from /usr/include/qt5/QtCore/qcoreapplication.h:37:0,
from /usr/include/qt5/QtCore/QCoreApplication:1,
from main.cpp:1:
/usr/include/qt5/QtCore/qcoreapplication.h:82:31: error: ‘QT_VERSION_MAJOR’ was not declared in this scope
enum { ApplicationFlags = QT_VERSION
...
I guess this is not related to the code, since the error happens on the first line of my code, which is just an include directive, but don't know how to proceed from here. This is from a Fedora 23 system, if it matters.
The problema was a missing package: qt5-base-devel.i686
After installing it with
sudo dnf install qt5-qtbase-devel.i686
the problem was gone.
Hello I need to compile a Qt project using openmp (built using cmake).
Up to now I used gcc-5 provided by homebrew but I would like to use clang (my taste...)
I installed clang-omp via homebrew install clang-omp but now when I try to compile my project (generated via cmake -DCMAKE_CXX_COMPILER=/usr/local/bin/clang-omp++ ..), I get this error:
cd /Users/tommaso/neutrino/debug/src && /usr/local/bin/clang-omp++ -DHAVE_HDF5 -DHAVE_JPEG -DHAVE_LIBCFITSIO -DHAVE_LIBCLFFT -DHAVE_LIBDF -DHAVE_LIBFFTW -DHAVE_LIBFFTW_THREADS -DHAVE_LIBGSL -DHAVE_LIBGSLCBLAS -DHAVE_LIBHDF5HL -DHAVE_LIBMFHDF -DHAVE_LIBNETPBM -DHAVE_LIBTIFF -DHAVE_NPHYSIMAGE -DHAVE_OPENCL -DHAVE_PYTHONQT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -DQT_PRINTSUPPORT_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_UIPLUGIN_LIB -DQT_UITOOLS_LIB -DQT_WIDGETS_LIB -DUSE_QT5 -D__VER=\"osx-cmake-v2.0-75.bdff6e3\" -I/Users/tommaso/neutrino/debug/src -I/Users/tommaso/neutrino/src -I/usr/include/hdf -I/usr/local/include/netpbm -I/Library/Frameworks/qwt.framework/Headers -I/usr/local/Cellar/hdf5/1.8.16_1/include -I/usr/include/python2.7 -I/Users/tommaso/neutrino/src/../../pythonqt-code/src -I/Users/tommaso/neutrino/src/../../pythonqt-code/src/gui -I/Users/tommaso/pythonqt-code/src -I/Users/tommaso/pythonqt-code/extensions/PythonQt_QtAll -I/Users/tommaso/neutrino/src/python -iframework /usr/local/opt/qt5/lib -isystem /usr/local/opt/qt5/lib/QtCore.framework/Headers -isystem /usr/local/opt/qt5/./mkspecs/macx-clang -isystem /usr/local/opt/qt5/lib/QtGui.framework/Headers -isystem /System/Library/Frameworks/OpenGL.framework/Headers -isystem /usr/local/opt/qt5/lib/QtSql.framework/Headers -isystem /usr/local/opt/qt5/lib/QtWidgets.framework/Headers -isystem /usr/local/opt/qt5/lib/QtSvg.framework/Headers -isystem /usr/local/opt/qt5/lib/QtPrintSupport.framework/Headers -isystem /usr/local/opt/qt5/include -isystem /usr/local/opt/qt5/include/QtUiTools -isystem /usr/local/opt/qt5/lib/QtMultimedia.framework/Headers -isystem /usr/local/opt/qt5/lib/QtNetwork.framework/Headers -isystem /usr/local/opt/qt5/lib/QtMultimediaWidgets.framework/Headers -I/Users/tommaso/neutrino/debug -I/Users/tommaso/neutrino/src/graphics -I/Users/tommaso/neutrino/src/doc -I/Users/tommaso/neutrino/src/pans -I/Users/tommaso/neutrino/src/pans/VISAR -I/Users/tommaso/neutrino/src/pans/colorbar -I/Users/tommaso/neutrino/src/pans/winlist -I/Users/tommaso/neutrino/src/../nPhysImage -I/Users/tommaso/neutrino/nPhysImage -isystem /usr/local/opt/qt5/lib/QtUiPlugin.framework/Headers -O3 -fopenmp -fopenmp -O0 -ggdb -D__phys_debug=10 -std=c++11 -Wall -fPIC -mmacosx-version-min=10.6 -o CMakeFiles/Neutrino.dir/neutrino.cc.o -c /Users/tommaso/neutrino/src/neutrino.cc
In file included from /Users/tommaso/neutrino/src/neutrino.cc:26:
In file included from /usr/local/opt/qt5/lib/QtSvg.framework/Headers/QtSvg:3:
In file included from /usr/local/opt/qt5/include/QtSvg/QtSvgDepends:3:
In file included from /usr/local/opt/qt5/include/QtCore/QtCore:4:
In file included from /usr/local/opt/qt5/lib/QtCore.framework/Headers/qabstractanimation.h:37:
In file included from /usr/local/opt/qt5/include/QtCore/qobject.h:41:
/usr/local/opt/qt5/include/QtCore/qstring.h:739:55: error: no type named 'u16string' in namespace 'std'
static inline QString fromStdU16String(const std::u16string &s);
It turns out (correct me if I'm wrong) that I need probably to compile qt with the same clang-omp compiler.
I thought no big deal but homebrew cries when I try this:
HOMEBREW_CC=clang-omp HOMEBREW_CXX=clang-omp++ brew install -s qt5
Error: Invalid value for HOMEBREW_CC: clang-omp
So is there a way to have Qt rebuilt using homebrew?
Is there a command to get the available compilers for homebrew?
Recompiling Qt with a different compiler probably is not going to solve the problem.
Have a look at this other question instead ...
It may also be a bug in Qt's header that can't detect your compiler properly and then wrongly assumes it has support for std::u16string
Or maybe you just forgot to add #include <string>
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