Important: Please read the Qt Code of Conduct -

[SOLVED]QtSerialPort installation - details would be welcome

  • Hi to everyone,

    and greetings to all forum members. After several years of programming Windows and embedded devices I've decided to try myself in the Linux domain. I'm coming from C# .NET so it is needless to say that I'm new to Linux and to Qt as well and I'm very well aware that it's going to be a steep learning curve.

    Anyway, I'd like to create a small Qt5 application which can communicate with one of my devices via a CP210x based USB-UART converter. I've already checked with dmesg | grep tty that my converter chip is recognised and connected as ttyUSB0.

    I installed Qt5 and went to QtSerialPort wiki "here": I've downloaded the serialport package as a tarball and extracted it to a folder.

    At the 'Building and Install' section of the wiki, I don't understand the steps. I'm supposed to create a 'serialport-build' folder near a 'serialport-src' but there is no such directory in the extracted folder. It is also not clear how to use the build in my projects. It would be greatly appreciated if someone would explain me the necessary steps to get me started. Thank you.

  • Lifetime Qt Champion


    The "serialport-src" means "name_of_the_folder_where_you_have_qtserialport_sources". In your case, the folder resulting from the extraction of the tarball.

    By the way, depending on how you have gotten Qt5 you might already have QtSerialPort, worth to check.

    Hope it helps

  • Hi SGaist,

    thanks for the reply. How can I check if my Qt5 installation has already have the QtSerialPort? Sorry for being dumb but I'm like stuck in a jungle.

  • Lifetime Qt Champion

    There are several possibilities, i think the fastest right now is from the command line:

    @find qt_source_folder -iname "qtserialport*"@

  • Thanks. Unfortunately it found nothing.

    However, in the meantime I managed to execute the following (after I've created a serialport-build folder):

    cd /home/notebook/WORK/Qt/qt-qtserialport/serialport-build
    qmake ../serialport-src/
    sudo make install

    Now I've got a directory with example, include and src folders, containing .h, .so, .prl, .o, .cpp files. How can I use them? The wiki says that I should add Qt +=serialport to my projects .pro file but it won't compile...probably I need to set the dependencies?

    There is another thing in the wiki:

    #include <QtAddOnSerialPort/serialport.h>
    #include <QtAddOnSerialPort/serialportinfo.h>

    I can't find such directory like 'QtAddOnSerialPort'.

  • Lifetime Qt Champion

    Are you sure you are using Qt 5 qmake ? If you also have Qt 4 dev-tools installed you might be using the wrong one

  • bq. Are you sure you are using Qt 5 qmake ? If you also have Qt 4 dev-tools installed you might be using the wrong one

    How can I check that?

  • Lifetime Qt Champion


    @which qmake@ will give you the complete path to qmake


    @qmake --version@ will give you the information about qmake/Qt

  • Thanks SGaist, I really appreciate your patience. I've received the following:

    notebook@notebook-K50IJ:~$ which qmake
    notebook@notebook-K50IJ:~$ qmake --version
    QMake version 2.01a
    Using Qt version 4.8.3 in /usr/lib/i386-linux-gnu

    However, in Qt Creator, I'm using Qt5.0.1 and Qt Creator 2.6.2.

  • Lifetime Qt Champion

    So it means that you compile QtSerialPort for Qt 4.8.3 (not a bad thing)

    You have to go back to your build directory, remove everything from it, and then run the same command as before but giving the full path to Qt 5 qmake i.e

    @/usr/local/PATH_TO_QT5_QMAKE/qmake ../qtserialport-src
    sudo make install
    Don't forget to make first and then make install, otherwise you will build as root

  • @Don’t forget to make first and then make install, otherwise you will build as root@

    Yes, I did it that way before and had to google how to delete all those locked folders. Before I try your suggestion I've got a question: I checked into usr/include folder and found a QtSerialPort directory with the header files serialport.h and serialportinfo.h (probably these are those header files which are mentioned in the wiki, but under 'QtSerialPort' directory instead of 'QtAddOnSerialPort'). Do I need to delete this usr/include/QtSerialPort directory (or uninstall it etc.) before I try your suggestion?

  • Lifetime Qt Champion

    If you got no use of QtSerialPort for Qt 4 you can do a @sudo make uninstall@ before removing the folder content.

    Otherwise, I'm pretty sure the include folder will be the same for Qt 5. The include files don't change but the libraries will.

    You'll have to change your code accordingly using QtSerialPort rather than QtAddOnSerialPort

  • Success! At least so far.

    In my custom project I placed the necessary includes:

    #include <QtSerialPort/qserialport.h>
    #include <QtSerialPort/qserialportinfo.h>

    and added

    QT += widgets serialport

    It compiles.

    Thank you for yor help!

  • Lifetime Qt Champion

    You're welcome !

    Don't forget to change the thread subject to solved

  • Done and thanks a million!

Log in to reply