QT5.2.1 :-1: error: Unknown module(s) in QT: serialport



  • Hi,
    I am trying to work with serial port communication in a little console application on linux and after some research i saw that the module for serialport is in the basic installation qt5.1 or superior.

    I added :
    '''QT += serialport'''
    to my .pro file and :
    '''#include <QtSerialPort/QtSerialPort>'''
    to my .cpp but it gives me the error :
    '''Unknown module(s) in QT: serialport'''

    I checked in the installation folder of qt5.2.1 and i found files related to this module but it seems qt don't find them. Also, when including <QtSerialPort/QtSerialPort> it don't find it but it seems to be able to find <QtSerialPort/QSerialPortInfo>.

    Do i have to transfert files to my application folder or am i missing a line somewhere in my .pro/.cpp files ?



  • @wowy said:

    #include <QtSerialPort/QtSerialPort>

    Hi,

    I think the right header file is #include <QtSerialPort/QSerialPort>. Probably an error in the Module's page



  • On which OS are you working? Under Ubuntu you have to install the Qt serialport package.



  • @cybercatalyst
    I am working on ubuntu 14.04.

    I tried getting the source ( https://wiki.qt.io/Qt_Serial_Port#Getting_the_source_code ) but i always had the error :
    fatal: unable to connect to code.qt.io:
    code.qt.io[0: 54.77.201.214]: errno=Connection timed out

    Is there any other way to download them ?

    EDIT : I downloaded it here :
    https://qt.gitorious.org/qt/qtserialport/source/da396bc54b776da682ffdcd2aa61f504d607bc12:

    I tried to follow the qtcreator instruction from here :
    https://wiki.qt.io/Qt_Serial_Port#Build_and_install_from_QtCreator

    I added install argument to my make and then tried to rebuild the project but i have a issue :

    /home/spi/Bureau/qtserialport/qt-qtserialport/src/serialport/qserialport.h:40: error: QtSerialPort/qserialportglobal.h: No such file or directory

    I checked, the file is in the project and in the src folder.


  • Moderators

    Hi @wowy ,

    I checked in the installation folder of qt5.2.1

    1. What is the full path to your installation folder?
    2. How did you install Qt 5.2.1?

    If you installed it from the Ubuntu repositories, install Qt Serial Port from the Ubuntu Software Center (libqt5serialport5-dev).

    I tried getting the source ( https://wiki.qt.io/Qt_Serial_Port#Getting_the_source_code )

    Don't do that. There is a high risk that you will end up with multiple copies of the library in your computer, and you will have a hard time debugging if your program links to the wrong version.

    Delete all the source code you downloaded and any binaries you built yourself. Use the official installers.



  • @JKSH
    But if i use the install from the ubuntu software center it will only install it in the qt5 version i installed using the USC, right ?

    I use qt creator with a qt5 kit and a qt4 kit, i manually installed the qt4 version and i would need to use the serial port too with this version.


  • Moderators

    Hi @wowy,

    Please answer the 2 questions in my previous post.

    But if i use the install from the ubuntu software center it will only install it in the qt5 version i installed using the USC, right ?

    Right.

    I use qt creator with a qt5 kit and a qt4 kit, i manually installed the qt4 version and i would need to use the serial port too with this version.

    You only asked for Qt 5 in your original post, so I gave you a Qt 5 solution. Anyway, try that first; focus on getting it working for Qt 5 first. Worry about Qt 4 later.



  • I got this problem too ! additionally, you should install libqt5serialport5-dev while libqt5serialport5 has been installed!



  • I know this topic is very old and I'm sure everyone on here has figured out a solution, but I wanted to post my solution to this problem. I did the following things for linking QSerialPort to an application using the static build of Qt 5.11.2:

    1. Build Qt with the -static tag. (Specifically, my configure command was this: "./configure -static -prefix ../PathToQt/ -skip webengine -skip location -skip wayland". I skipped wayland and location because they had errors when compiled against std-c++11)
    2. Copy "libQt5SerialPort.a" from /PathToQt/qtserialport/lib/ to your project directory
    3. Copy "qserialport.h", "qserialport.h", and "qserialportinfo.h" from the /PathToQt/qtserialport/src/serialport to your project directory
    4. Remove "QT += serialport" from your .pro file if it's there.
    5. Change "#include <QSerialPort>" to "#include "qserialport.h" and "#include <QSerialPortInfo>" to "#include "qserialportinfo.h" where necessary

    Hope this helps!



  • @MissingNo218 I forgot to add: You also have to add "LIBS += libQt5SerialPort.a" to your .pro file


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.