Problems when adding serialport module in Qt project
-
@J.Hilk The Manage Kit button shows the settings reported below, in which I can't find any information regarding the Qt version in use:
If from terminal I write
$ qmake --version
I obtain the following:
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
Is it relevant the "qt4" shown in that prompt?
Thanks. -
@douglas
well, there we have your problemyou have no QtLibary selected to your kit. Se if you can actually select a QtVersion from that dropdown menu. If you can't than you need to install an actual qt version.
I would recommend the online installer from the Webside.
-
@J.Hilk Thanks, I added the version as shown below:
Now, since I should have Qt5, I added the serialport support in my .pro file, but the "unknow module" error still remains. I saw another thing that seems not so clear to me: I run Qt Creator from linux terminal, and when I open my project the terminal shows the following lines, marked in red, in which appears Qt4. Can this be related to the serialport module error?
thank you again. -
@jsulm when I spoke about Qt 5.6 I was referring to the "About Qt Creator" window shown above. Now I selected Qt 5.7.1 as the version for my kit. But the serialport module isn't recognized yet. What I should do to correctly install QtSerialPort for my actual version?
-
Is it me or are you trying to build your project for an embedded system ?
I see that you are trying to use an arm compiler, did you cross-compile Qt for your device ? -
Sur it does, you are trying to install the desktop version of the driver and then, use it to do cross-compilation.
-
@SGaist I see. So, if I need to cross-compile, which steps should I follow in order to use the serialport in my project?
Are there different libraries or drivers I need to install on my host PC?
The target linux embedded device runs Linux Yocto. -
@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!