A header paths error in Qt when building with Cmake - qt

It's not answer, but yet another question! While compiling a cmake generated ninja build for Qt, we get such an error - #include "../../../../../../../e:/github/Qt/qtbase/src/corelib/animation/qparallelanimationgroup.h", or something like this. Of course, the file won't be found.
Where, I gess, is the fault - in cmake or in a cmake script for Qt building?
It happens from version into version, when you build QT a 'disk-away' far from its sources location.
As it is generated automatically, it should be found and corrected in Qt source files!

Related

How to set up poppler library in Qt for embedded device?

The goal is to show pdf's on my target => imx6 board + display. My host's OS is Linux.
So far i'm having a program written in Qt 5.
It compiles fine and i'm able to see it on the display.
To show some pdfs i would like to use the poppler library.
The problem is that i'm not able to get this done. Properly ...
My steps so far:
I did the basic installation of poppler like it is described in the INSTALL file.
mkdir build
cd build
cmake ..
make
make install
then added
INCLUDEPATH += /home/user/poppler/include/poppler/qt5
LIBS += -L"/home/user/poppler/lib" -lpoppler-qt5
to my .pro file
and the #include <poppler-qt5.h> to my .cpp file.
And the result when running is this:
/home/user/poppler/lib/libpoppler-qt5.so:-1: error: file not recognized: File format not recognized
:-1: error: collect2: error: ld returned 1 exit status
Now i have just two ideas. First one is to cross-compile the poppler source code. (I tried this with a toolchain file but failed :'D)
Second idea is to put the library into Qt together with my project and compile it there - maybe that could work. I just don't know how. Help.
I'm also open for something else then poppler - i just want to show pdf's.
The problem, here, is you are somehow compiling Qt projects for ARM, using the corresponding toolchain and sysroot and ABI, and you can not just link to libraries you compiled for, say, x86_64, because they're just binary incompatible.
In the very lucky case you managed to configure creator for cross compilation, just make a creator project for the poppler library, using cmake, and configure the project with the same kit you use for the imx6 applications. Once you have it built for ARM, you can proper link it in your app, providing the full path to LIBS in the .pro file.
In case you're using Yocto, instead, just make a recipe for poppler. In case you're not, maybe you should.

CMake doesn't find Qt5QuickCompiler

I'm trying to build a Qt Quick Controls application with CMake. I use the following documentation:
http://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html
When running CMake, I'm getting this error:
By not providing "FindQt5QuickCompiler.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt5QuickCompiler", but CMake did not find one.
Could not find a package configuration file provided by "Qt5QuickCompiler"
with any of the following names:
Qt5QuickCompilerConfig.cmake
qt5quickcompiler-config.cmake
at this line:
FIND_PACKAGE(Qt5QuickCompiler)
Obviously CMake doesn't find Qt5QuickCompiler. I checked in my Qt folder (C:\Qt) but it's not there. Yet I could run this application with QMake.
What do I need to set in order to find Qt5QuickCompiler?
I just stumbled upon the same issue with Qt 5.12 under Linux. The documentation under https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html currently seems to be wrong.
Use QuickCompiler after COMPONENTS in the Qt5 find_package instead of trying to add it via find_package(Qt5QuickCompiler). Adapting the example from the link, use
find_package(Qt5 COMPONENTS Quick Core Network QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
instead of
find_package(Qt5 COMPONENTS Quick Core Network)
find_package(Qt5QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
The error is pretty clear: CMake doesn't have a module for the Qt5QuickCompiler to find it. It just doesn't know what it is. I've just checked the corresponding cmake folder and it doesn't have that file. I'm not sure what that Qt documentation page is talking about but there is no such a file in the CMake distribution. Maybe Qt sources have this file somewhere?
You need to build Qt5 with Qt Quick compiler which you can download from http://www.qt.io/qt-quick/. In the build directory of Qt Quick compiler, you will find Qt5QuickCompilerConfig.cmake.
Copy the path to this directory, and add to CMAKE_PREFIX_PATH like this
cmake -DCMAKE_PRFEIX_PATH=<pathToFile> <pathToSrcDirOfYourProject>

Error in OpenCV configuration for Qt Creator

I followed these instructions in the configuration of OpenCV SDK for using it in Qt Creator IDE, but I couldn't conclude point 6.5, due to configuration errors in Cmake-GUI. I setup the configuration in CMake of the compilers gcc and g++ contained in Qt folder for MinGW32, and all looks Ok. But when Cmake-GUI starts the process of build configuration it ends up saying
"Error in configuration process, project files may be invalid".
It can't find the following:
QT_QMAKE_EXECUTABLE;
Qt5Concurrent_DIR;
QT5Core_DIR;
QT5Gui_DIR;
QT5Test_DIR;
QT5Widgets_DIR.
After this issue I tried to go on with following points of configuration tutorial, without reaching the final instruction of mingw32-make install. I'm using the following versions of softwares: Qt 5.3.0, OpenCV 2.4.9, CMake 2.8.12.2. My OS is Windows 7.
How can I recover the missing Qt files in CMake configuration?
Is there an alternative way for configuring OpenCV with Qt (like using precompiled build of OpenCV libraries)?
You just need to indicate CMake the correct paths to each one. Click oh the path to browse and set each one individually:
QT_QMAKE_EXECUTABLE;
For this one, you need to search inside the Qt installation folder for the /bin directory. On it, you' ll find the qmake.exe. In my case it was C:/Qt/5.3/winrt_x64/bin/qmake.exe
All the following ones are in the Qt's /lib/cmake directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake :
Qt5Concurrent_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Concurrent
QT5Core_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Core
QT5Gui_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Gui
QT5Test_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Test
QT5Widgets_DIR.
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Widgets
Then click generate. It' ll show a new error and ask you for the QT5OpenGL_DIR. Just as before, show CMake the correct directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake/Qt5OpenGL. Finally, click Configure again, and then Generate, and now you're done creating the build files.
You have to specify the location of Qt manually by passing it as an argument for QT5Core_DIR. Qt5_DIR or CMAKE_PREFIX_PATH does also the trick.
Example
Given your Qt 5 is installed at /opt/selfcompiled/Qt5. When calling cmake, add the flag from above:
cmake -DQt5_DIR=/opt/selfcompiled/Qt5 <pathToSourceDir>
Once the Qt 5 directory is set and found by CMake, all the other variables related to Qt 5 should be found from there, too.

Warning while building project using Qt 5.1 on OSX

I am getting two warnings while trying to build Qt projects on Mac (using QtCreator).
warning: No .qmake.cache is present. This significantly slows down
qmake with this makespec. warning: Call 'cache()' in the top-level
project file to rectify this problem.
The warning instructs to call cache() in the top level project, but I don't find any documentation on how I should do that.
I see some bugs logged on qt
https://bugreports.qt.io/browse/QTBUG-31340
https://bugreports.qt.io/browse/QTBUG-30586
I know this is just a warning, but I am interested in fixing it. Is there any workaround to fix it?
The solution is to call cache() in your main .pro file.
Then run qmake (from the QtCreator build menu) and rebuild the project.
The warning should be gone.
Example .pro:
cache()
QT += ...
//the rest of the .pro file

Forcing specific version of QT in .pro file

I'm searching for a way to force a specific version of QT in a .pro file. To be more specific, I'd like to force qmake to use only QT 5.x version with my project instead of QT 4.x and QT 5.x
Is there a way to do so?
PS: I'm not asking for a way to stop/halt the compile process (aka check QT version, and if lower than 5.x just throw qFatal/equivalent). I'm looking for a way to actually choose which version to use while generating the Makefile with qmake
You can throw a error if a user is running qmake with a version you do not want him to use. ex:
lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5")
I really doubt you can do this. qmake is a part of framework and goes together with libraries. When you say Qt of specific verion you mean only libraries, but it is not correct.
To use specific version of Qt, you actially need to run different version of qmake. If you are using QtCreator - you should select it in project's options, if not - type absolute path to file qmake. You can find out, which version of Qt qmake uses, you can type qmake --version.
As Amartel wrote in his answer, you should point to the correct qmake version (check it by typing qmake --version in the console)
It might be that your project has been generated using the wrong qmake executable and some files are not removed even if you issue a nmake clean or make clean.
Check that there are no Makefile in the source tree after the clean (these files will typically contain the path to the qt version to use, and if not regenerated correctly will point to the wrong Qt version).

Resources