Problems when adding serialport module in Qt project
-
@jsulm I already set up the project in order to cross-compile for my target: in fact, I have already managed to run my application on the target device. The problem is the serial port module: I did not succeeded in including it into my project. Are there any particular hints to follow in the case of cross-compilation?
Thank you! -
@douglas
How did you cross-compile for your target device?I would asume you cloned the qt-sources from git or something similar. However did you crosscompile the whole Framework or only part of it? For any Qt-Program to run you'll need only QtBase, however serialport is a plugin and needs to be compiled seperately.
-
@Pablo-J.-Rogina , after the Qt Creator installation, I followed the indication from 2.1 to 2.7 chapter here:
http://variwiki.com/index.php?title=Yocto_Qt_Creator&release=RELEASE_MORTY_V1.0_DART-6UL#QtCreator_configuration
in which, as far as I see, the environment is configured to cross-compile for my target device.
Now, I am able to create a simple GUI application and run it on my target device, but I can't add the serialport component (in order to manage a RS485 communication) in my project.
Unfortunatelly, I'm a beginner in this matter!
Thanks a lot! -
@douglas said in Problems when adding serialport module in Qt project:
Now, I am able to create a simple GUI application and run it on my target device
Ok, that's a great step. Reading briefly the link you posted to that wiki page, I assume you setup your environment in a Linux PC and using Qt Creator there, you built that simple GUI app that Qt Creator deployed and run in your device.
If that's correct, I'd try the following:
- from command line in let's say /home/douglas/projects do
cd /home/douglas/projects git clone git://code.qt.io/qt/qtserialport.git -b 5.9 cd qtserialport
so you should now have a folder /home/douglas/projects/qtserialport will sources for Qt serial port module release 5.9 (the Qt release should match what you have in your dev environment/device, you didn't stated it so far).
2. run commands:/opt/fslc-x11/2.2.1/sysroot/x86_64-fslcsdk-linux/usr/bin/qt5/qmake make make install
once build and install finishes, you should have the .so shared library and headers into the proper location under your host PC (I couldn't figure out the proper location from the wiki page). But look for something like this (version shuold be the one you cloned...):
./include/QtSerialPort/qtserialportversion.h ./include/QtSerialPort/qserialportinfo.h ./include/QtSerialPort/qserialportglobal.h ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialport_p.h ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialportinfo_p.h ./include/QtSerialPort/qserialport.h
and
./lib/libQt5SerialPort.so
if you succeed here, then you should be able to create a project file (.pro) for your application and add the serial port modulie like this:
... QT += serialport ...
and the magic will flow.
-
@Pablo-J.-Rogina Thanks a lot for your post, I'll now begin to put it into practice. I have just one doubt: if I run:
qmake --version
I obtain:
QMake version 2.01a Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu
So, if I'm not wrong, the installed version of Qt is the 4.8.7 (quite old). When you stated, in your #1 step, "git clone git://code.qt.io/qt/qtserialport.git -b 5.9" were you assuming my Qt version was 5.9? In other words, the serialport version and the installed qt version should be the same?
If so, how can I upgrade from my actual Qt version to the latest one?
Thanks a lot! -
First you should find out which Qt versions you have on your computer. Qt 4.8.7 is surely from Ubuntu and is a native Qt - you build programs that run on your computer. What you want, is a cross Qt, to run programs on your embedded device.
As you said you have already done this, you surely have a second Qt version (I cannot tell you which one it is). And this Qt version has a qmake which you need to call to compile Qt programs against this Qt library.
Regards
-
@aha_1980 Thanks. In Qt Creator I set Qt 5.7.1 in the "Qt Version" for the selected kit for my project. Now I can add the serialport module in my .pro file and build the app, but when I try to run it on my target device, the application does not start and the following error appears:
error while loading shared libraries: libQt5SerialPort.so.5: cannot open shared object file: No such file or directory
Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?
Thank you! -
@douglas said in Problems when adding serialport module in Qt project:
Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?
You're already on the right track. You need to cross-compile QtSerialPort for your embedded device, and then you need to deploy (copy over) these libraries to the device, because your final app is also running there.
-
@aha_1980 Ok,thanks! I just did the following on my host PC:
$ git clone git://code.qt.io/qt/qtserialport.git $ mkdir qtserialport-build $ cd qtserialport-build $ qmake ../qtserialport/qtserialport.pro
but the last command (qmake) gives the following:
Project MESSAGE: Cannot build current QtSerialPort sources with Qt version 4.8.7. Project ERROR: Use at least Qt 5.0.0 or try to download QtSerialPort for Qt4.
It is clear that I need to use a newer qmake, perhaps the default one is an older version. How can I run that command with a qmake version 5? Where should it be located? Or how can I "change the default one"?
Thanks for your patience. -
@aha_1980 Done, I found the qmake for version 5 and run the qmake command.
Now, when I run themake make install
this error appears:
fatal error: qdeadlinetimer.h: File o directory non esistente compilation terminated.
Which can be the solution?