Results 1 to 4 of 4

Thread: Qserialport issue in QT4

  1. #1
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qserialport issue in QT4

    Hello,

    I try to do a small test on a RS232 modem (very very old modem, but 100% functional).
    I had a look on the Internet and saw a small example on Qserialport library for QT4. I installed it and when trying to compile, here are the errors:

    (.text.startup+0x3e):-1: error: undefined reference to `QSerialPort::QSerialPort(QObject*)'
    (.text.startup+0x66):-1: error: undefined reference to `QSerialPort::setPortName(QString const&)'
    (.text.startup+0x8e):-1: error: undefined reference to `QSerialPort::setBaudRate(int, QFlags<QSerialPort:irection>)'
    (.text.startup+0x9e):-1: error: undefined reference to `QSerialPort::setDataBits(QSerialPort:ataBits)'
    ...
    etc.

    Same err. for all related QserialPort class members

    Before posting here I had a look on other posts and internet, so I added also QT += serialport in the .pro file, but same result


    Here are my files:

    Qt Code:
    1. // main.cpp
    2.  
    3. #include <QtCore/QCoreApplication>
    4. #include <QtSerialPort/QSerialPort>
    5. #include <QtSerialPort/QSerialPortInfo>
    6.  
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication a(argc, argv);
    11.  
    12. QSerialPort serial;
    13. serial.setPortName("com1");
    14. serial.setBaudRate(QSerialPort::Baud9600);
    15. serial.setDataBits(QSerialPort::Data8);
    16. serial.setParity(QSerialPort::NoParity);
    17. serial.setStopBits(QSerialPort::OneStop);
    18. serial.setFlowControl(QSerialPort::NoFlowControl);
    19. serial.open(QIODevice::ReadWrite);
    20. serial.write("firs string to serial");
    21.  
    22. serial.close();
    23.  
    24. return a.exec();
    25. }
    To copy to clipboard, switch view to plain text mode 


    and the .pro file|:


    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-12-11T00:53:45
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core serialport
    8.  
    9. QT -= gui
    10.  
    11. TARGET = serial
    12. CONFIG += console
    13. CONFIG -= app_bundle
    14.  
    15. TEMPLATE = app
    16.  
    17.  
    18. SOURCES += main.cpp \
    19. serial_intf.cpp
    20.  
    21. HEADERS += \
    22. serial_intf.h
    To copy to clipboard, switch view to plain text mode 

    Don't consider serial_intf.h It is intended for future use, but contains nothiing in it

    Thank you.

    Costin

  2. #2
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qserialport issue in QT4

    The linker doesn't find the QtSerialPort library. Check the linker options and verify the lib is found under the according path. If it isn't your Qt installation may be configured such that the lib isn't built.

    What's your platform?
    How did you install Qt?
    How do you invoke the linker (IDE/command line/...)?

  3. #3
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qserialport issue in QT4

    For Qt4 need add CONFIG += serialport instead of QT += serialport. Please be more attentive and read Wiki.

  4. #4
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qserialport issue in QT4

    Hello kuzulis, your solution worked well. Thank you.



    Costin

Similar Threads

  1. QSerialport in multithread
    By snow_starzz in forum Newbie
    Replies: 3
    Last Post: 3rd December 2013, 11:18
  2. Replies: 12
    Last Post: 20th June 2013, 15:02
  3. setting QSerialPort port
    By saman_artorious in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2013, 10:45
  4. Qt5 cmake and QSerialPort
    By Chris.Burner in forum Newbie
    Replies: 1
    Last Post: 21st April 2013, 17:13
  5. inbiza-labs qserialport on arm platform
    By sean_h in forum Newbie
    Replies: 0
    Last Post: 28th March 2012, 12:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.