install qcharts module to yocto sdk - c++

I try to cross-compile qt chart example for a yocto platform. I do following steps to compile my qt programs:
source /opt/myimage/2.1.2/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
qmake -o Makefile areachart.pro
make
But When I add QT += charts to any project run qmake like qmake -o Makefile areachart.pro I hit this error:
Project ERROR: Unknown module(s) in QT: charts
Here is the output of qmake -v:
QMake version 3.0
Using Qt version 5.7.0 in /opt/myimage/2.1.2/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib
Should I add qtcharts module my yocto SDK to be able to compile the example? if yes how?
For some reasons I was able to cross-compiled Qt from source using qtcreator and get the binary files for qt examples and qtchart library itself. I also run the qt examples on my target platform by putting resulting libQtCharts.so and other files manually in /usr/lib/ and /usr/include/ on the target and I was able to draw the charts on target.
However, what I need is to include the charts in my project and run qmake steps as mentioned above. But what I get is the Project ERROR: Unknown module(s) in QT: charts
I have tried to put libQtCharts.so which I got from compiling qt source manually in /opt/myimage/2.1.2/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib but still not able to get the make file with qmake -o Makefile areachart.pro

As you pointed out, you need qtcharts package (also with qtcharts-dev to be precise) in your SDK. You also need qtcharts package on your target (i.e. in your image), otherwise the runtime library will be missing when you will execute your binary on the target.
The addition of the package depends on the method of building the SDK. The preferred one is a populate_sdk task, so I will describe it here (it will also add the package to your target).
The command to build the SDK is bitbake your_image -c populate_sdk. Add following lines to your_image.bb recipe to add the qtcharts package to the image (line 1) and other Qt5 stuff for SDK (line 2).
IMAGE_INSTALL += "qtcharts"
inherit populate_sdk_qt5
You can also put these lines into your_image.bbappend if you don't want to edit the image recipe directly.
The inherit populate_sdk_qt5 is specific (and required) for Qt5 packages, because other stuff is needed for SDK (e.g. qt.conf, some tools).

Related

How to build a project under the src directory of Qt?

I found a .pro file 5.12.1\Src\qtbase\src\plugins\platforms\windows\windows.pro and opened it in Qt Creator. After configuring a MingW kit, I tried to build the project. But I got this error;
error: vulkan/vulkan.h: No such file or directory
#include <vulkan/vulkan.h>
Do I need to configure something before building the project? I do not want the vulkan support, just want to compile it successfully. I remember if I build the whole Qt src, I need to run a command like "configure xxxxx" in the src directory. Now I do not want to build whole Qt, just this project. There is a line in windows.pro that seems related to this problem.
qtConfig(vulkan): QT += vulkan_support-private
How should I do to remove the need for the vulkan stuff in order to build it successfully?
Yes, you will need to configure things. I suggest you read up on Building Qt 5 from source to understand what is involved.

How to compile qtwebkit in qt-5.8

I have compiled QT-5.8 from github successfully, each submodule is cloned by init-repository provided by QT. However, in Qt5.8, it has removed qtwebkit.
But my app needs qtwebkit, so I clone qtwebkit submodule and qmake it.
However, it shows the compilation errors
( test -e Makefile.api || /usr/local/Qt-5.8.0/bin/qmake -o Makefile.api /home/tumh/qt5/qtwebkit/Source/api.pri ) && make -f Makefile.api
make[1]: Entering directory '/home/tumh/qt5/qtwebkit/Source'
make[1]: *** No rule to make target '/home/tumh/qt5/qtwebkit/Source/WebCore//libWebCore.a', needed by '../lib/libQt5WebKit.so.5.8.0'. Stop.
make[1]: Leaving directory '/home/tumh/qt5/qtwebkit/Source'
Makefile:40: recipe for target 'sub-api-pri-make_first-ordered' failed
make: *** [sub-api-pri-make_first-ordered] Error 2
I have no idea that how to compile a single submodule in QT.
Any suggestion is appreciated.
thanks!
You should take tarball of webkit from official releases. It should build fine with Qt-5.8.
The following describes how to compile qtwebkit module so it is usable with Qt 5.9.9. I assume the process is similar if not identical for Qt 5.8.
An overview of the process
All of the required components should be compiled using one tool chain. I suggest using the one installed with Qt.
You gonna need ICU compiled, the source code can be obtained from the official site.
The source code of qtwebkit module that we want to compile is available here (thx #J. Doe for the link!)
Regardless of the operating system you are working on, in order to compile qtwebkit module you gonna need the following additional tools:
ruby
gperf
flex
bison
python 2
Qtwebkit module depends on declarative module. It becomes available when qtquick1 is installed.
It is assumed that Qt 5.9.9 is installed. I was using these installers.
The process takes some time so if you need the module ready ASAP go to the last section (What if you cannot perform some of the above steps).
Compiling on Windows (tested on Win10)
On Windows I recommend using chocolatey to install additional tools.
Compiling ICU
Install msys2 package via chocolatey. It allows to use the scrips provided with ICU source code with very few modifications.
Installation script requires make program available. It doesn't matter if mingw32-make is virtually (of even literally) the same tool. Copy mingw32-make.exe and rename it to make.exe.
Using cmd with integrated mingw tools (installed along with Qt) open msys2 shell forwarding the PATH variable.
msys2_shell -use-full-path
Go to the ICU source code directory (mine was C:\icu\source) and run
./runConfigureICU MinGW -prefix=$PWD/../dist
(It is expected to encounter "unknown platform" issue, no worries)
Now run:
gcc -dumpmachine
Save the output, in my case it was i686-w64-mingw32.
Using this result execute:
./configure -build=i686-w64-mingw32 -prefix=$PWD/../dist
(modify build parameter according to the result of the previous step)
Now, you should be able to compile ICU with:
make & make install
(If you want to speed things up you can engage multiple CPU cores in the above process. For example in order to engage 777 cores execute make -j777 & make install)
Assuming your ICU source code was in C:\icu\source directory, the result of the compilation should be in C:\icu\dist.
Compiling qtwebkit module
As said in the first section, compiling qtwebkit module requires additional tools.
They can be installed via chocolatey using the following command:
choco install ruby gperf winflexbison python2
This, among others, installs win_flex.exe and win_bison.exe. As of this writing these executables are located (at least in my case) in C:\ProgramData\chocolatey\lib\winflexbison\tools .
The qmake checks for programs named bison.exe and flex.exe. So I have copied both win_flex.exe and win_bison.exe and renamed them flex.exe and bison.exe accordingly.
The last step is to add both of these programs to PATH variable.
To do so execute (in cmd with integrated mingw tools) the following command:
set PATH=C:\ProgramData\chocolatey\lib\winflexbison\tools;%PATH%
Additionally you need to point to the directory where includes and libs of compiled ICU are located. I have done it like this:
set PATH=C:\icu\dist\bin;%PATH%
set INCLUDE=C:\icu\dist\include;
set LIB=C:\icu\dist\lib;
Above assumes that prior to executing this commands there was no variables named INCLUDE and LIB set in the currently used cmd.
Finally, qmake process checks for a variable named SQLITE3SRCDIR.
As suggested by this answer you can set it to sqlite sources provided with Qt. In my case it was done like this:
set SQLITE3SRCDIR=C:\Qt\Qt5.9.9\5.9.9\Src\qtbase\src\3rdparty\sqlite
Now (using the same cmd) go to the directory where Qt sources are located and execute configure.bat. I have done both of these steps with:
cd C:\Qt\Qt5.9.9\5.9.9\Src
configure.bat
Finally, extract the downloaded source code of the qtwebkitmodule to the sources directory of Qt (C:\Qt\Qt5.9.9\5.9.9\Src in my case) and make a module. I have done it like this:
cd qtwebkit-opensource-src-5.9.0
mkdir build
cd build
qmake -r ..
make
make install
It is strongly recommended to utilize multiple cores in the make process, otherwise prepare yourself for a very long compilation.
Now you should be able to use webkit and webkitwidgets in your Qt projects.
Compiling on Linux (tested on LUbuntu 18.04)
I suggest using compilation tools provided with Qt instead of default make and g++ compiler. To do so I have exported path to the tools provided with Qt like this:
export PATH=/home/$USER/Qt5.9.9/5.9.9/gcc_64/bin/:$PATH
You gonna need ICU compiled. I suggest using version 56.1 as it is the same shipped with Qt 5.9.9. The compilation process is almost identical as it was described for Windows. the only difference is that you run:
./runConfigureICU Linux/gcc --prefix=$PWD/../dist
and later configure script can be omitted on Linux.
On lUbuntu 18.04 I needed the following packages installed:
apt-get install ruby bison gperf python flex perl libx11-dev xserver-xorg-dev xorg-dev libpulse-dev libsqlite3-dev
As with compiling qtwebkit on Windows, you gonna need qtquick1 module installed.
I have encountered an error saying that some headers related to OpenGL were missing. If you have the same problem then in my case installing libgl1-mesa-dev package solved it.
Now extract source code of qtwebkit module sources directory of your Qt installation. In my case it was "/home/$USER/Qt5.9.9/5.9.9/Src".
Modify WTF.pri file and add the path to ICU includes and libs after the first INCLUDEPATH. In my case it was done like this:
...
INCLUDEPATH += /home/$USER/icu/dist/include/
LIBS += -L/home/$USER/icu/dist/lib/
...
Note '-L' is placed before path pointing to libs.
Now you should be able to compile qtwebkit module in usual manner:
mkdir build
cd build
qmake -r ..
make & make install
What if you cannot perform some of the above steps
You can always try to use prebuild binaries:
https://download.qt.io/snapshots/ci/qtwebkit/5.9/latest/qtwebkit/
or unofficial fork of the qtwebkit module:
https://github.com/qtwebkit/qtwebkit/releases

Qt-GStreamer: PKGCONFIG not found

I am pretty new to setting the Qt Creator environment in Linux.
I will cross compile this demo program to the Yocto Project i.MX6. This demo program needs to use Qt-GStreamer
in demo.pro
There is these 2 lines
CONFIG += link_pkgconfig
PKGCONFIG += Qt5GLib-2.0 Qt5GStreamer-1.0 Qt5GStreamerUi-1.0 Qt5GStreamerUtils-1.0 Qt5GStreamerQuick-1.0
at compile in the Desktop, it shows
error: Qt5GLib-2.0 development package not found
This applies to all the other packages as well.
I know that it tells me that I am missing the package for the Qt Gstreamer.
However, when I look at this thread, the answer is
export PKG_CONFIG_LIBDIR=/home/anisha/Desktop/newGSTr/qt-gstreamer-0.10.3/lib/x86_64-linux-gnu/pkgconfig
But, from what I have downloaded in Qt Binding-GStreamer qt-gstreamer-0.10.3 Does not have the lib folder inside.
I have also used cmake to work with the CMakeList.txt inside the folder but encounter Qt missing packages error.
Could someone help me on setting up those packages?

Opencv windows 7 cmake mingw-32 make error

I wanted to ask about an error I got when compiling opencv for windows7, I am following this
http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml
and I have gotten to the part where both configure and generate commands on cmake are successful, but
when using mingw32-make command in the directory where cmake builds opencv, I am getting the following error:
fatal error: QApplication: No such file or directory
this happens in the file windw_QT.h which is located on the sources folder in openc, my exact path is
C:\Users\lenovo\Desktop\OpenCV248\opencv\sources\modules\highgui\src\window_QT.h
to be honest I could handle the cmake errors when it didn't know where to find the QT libraries, but I have no idea why compiling the sources yields this error, isn't QApplication supposed to exist in the very same folder as highgui.h
Based on your comment, you seem to have used cmake 2.6 for dealing with Qt 5. If you take a look at the Qt 5 cmake manual, you can see that you would need at least 2.8.3, but 2.8.11 is recommended:
CMake is a 3rd party tool with its own documentation. The rest of this manual details the specifics of how to use Qt 5 with CMake. The minimum version required to use Qt5 is CMake 2.8.3, but 2.8.11 is recommended.
Once you update, this all should start working.

Statically linked app with Qt gives error: Failed to load platform plugin "windows"

I have built Qt 5.0.1 statically in VS 2010 under Windows 7 x64. The configuration parameters were
configure -debug-and-release -opensource -confirm-license -platform win32-msvc2010 -nomake examples -nomake tests -no-webkit -static
and I performed the build with jom with following parameters:
jom -j 4
The build process was successful and I can find all the libs and link my app with Qt statically. Now the problem is that when I try to run the application, it gives me an error
Module: 5.0.1
File: kernel\qguiapplication.cpp
Line: 781
"Failed to load platform plugin "windows". Available platforms are:"
But below this error, it does not show up any platforms. I encountered the same error while linking with Qt dynamically. I got rid of that by placing dependency DLLs (qt5core.dll, qt5gui.dll etc) in the same directory of my exe. But I can't figure out a way this time.
After static build of Qt, the DLLs in the plugins/platforms/ folder are gone and they are replaced by libs. I have also tried to statically link with qwindows.lib but to no avail.
Any idea?
Regards.
To check what DLL are needed to deploy your application on Windows, use dependency Walker (http://www.dependencywalker.com/).
According to the documentation page Qt for Windows - Deployment some DLL are required to deploy a Qt application on Windows platforms:
qwindows.dll
icudtXX.dll
icuinXX.dll
icuucXX.dll
libGLESv2.dll
libEGL.dll
Depending on the compiler you use to compile the application, some other libraries may be required:
MSVC specific libraries:
msvcrXX.dll
msvcpXX.dll
MinGW specific libraries
libgcc_s_dw2-1.DLL
libstdc++-6.dll
Note: in all these files, replace XX by the current version of the DLL on your system.
If you didn't build Qt statically (default), you will also need Qt5 DLL depending on Qt module you use in your application. Example:
Qt5Core.dll
Qt5Test.dll
Qt5Network.dll
etc.
All these DLL can be found in "bin" folder, under your Qt installation dir.
EDIT
Recently, Qt developers created a tool named windeployqt.exe which helps you to gather all required library to deploy an application:
Usage: windeployqt [options] [file]
Qt Deploy Tool 5.3.0
The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:
windeployqt <path-to-app-binary>
If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:
windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
Options:
-?, -h, --help Displays this help.
-v, --version Displays version information.
--dir <directory> Use directory instead of binary directory.
--libdir <path> Copy libraries to path.
--debug Assume debug binaries.
--release Assume release binaries.
--force Force updating files.
--dry-run Simulation mode. Behave normally, but do not
copy/update any files.
--no-plugins Skip plugin deployment.
--no-libraries Skip library deployment.
--qmldir <directory> Scan for QML-imports starting from directory.
--no-quick-import Skip deployment of Qt Quick imports.
--no-translations Skip deployment of translations.
--no-system-d3d-compiler Skip deployment of the system D3D compiler.
--compiler-runtime Deploy compiler runtime (Desktop only).
--no-compiler-runtime Do not deploy compiler runtime (Desktop only).
--webkit2 Deployment of WebKit2 (web process).
--no-webkit2 Skip deployment of WebKit2.
--json Print to stdout in JSON format.
--list <option> Print only the names of the files copied.
Available options:
source: absolute path of the source files
target: absolute path of the target files
relative: paths of the target files, relative
to the target directory
mapping: outputs the source and the relative
target, suitable for use within an
Appx mapping file
--verbose <level> Verbose level.
Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth clucene concurrent core declarative designercomponents designer gui
clucene qthelp multimedia multimediawidgets multimediaquick network nfc opengl
positioning printsupport qml quick quickparticles script scripttools sensors
serialport sql svg test widgets winextras xml xmlpatterns
Arguments:
[file] Binary or directory containing the binary.
I just had the same problem, so here is my solution:
First of course build QT with the -static parameter.
Add the following libs to your build:
Qt5PlatformSupport.lib
qwindows.lib
imm32.lib
Add the following path to your library paths:
$(QTDIR)\plugins\platforms
In your code (preferably main.cpp) add the following line:
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
The resulting build should not depend on any qt-related dlls.
If you are using libGLESv2.dll, then you must include libEGL.dll, too. See
Deploying Qt C++ Application from Visual Studio qwindows.dll error
It's a Qt platform plugin issue. Using qt.conf resolved the problem for me on MacOS.
It doesn't matter if you link Qt staticly on not.
I tried to staticly link to libqcocoa.a (or qwindows.lib) without success. I will let you know if i succeed.
Just do the following steps:
Go to bin folder in your Qt installation directory
Copy all files with .dll extension
Past them to C:\Windows\System32 for 32 bits or C:\Windows\syswow64 for 64 bits.
Tada! you will never see that irritating message again