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