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:
// main.cpp
#include <QtCore/QCoreApplication>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
int main(int argc, char *argv[])
{
QSerialPort serial;
serial.setPortName("com1");
serial.setBaudRate(QSerialPort::Baud9600);
serial.setDataBits(QSerialPort::Data8);
serial.setParity(QSerialPort::NoParity);
serial.setStopBits(QSerialPort::OneStop);
serial.setFlowControl(QSerialPort::NoFlowControl);
serial.write("firs string to serial");
serial.close();
return a.exec();
}
// main.cpp
#include <QtCore/QCoreApplication>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSerialPort serial;
serial.setPortName("com1");
serial.setBaudRate(QSerialPort::Baud9600);
serial.setDataBits(QSerialPort::Data8);
serial.setParity(QSerialPort::NoParity);
serial.setStopBits(QSerialPort::OneStop);
serial.setFlowControl(QSerialPort::NoFlowControl);
serial.open(QIODevice::ReadWrite);
serial.write("firs string to serial");
serial.close();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
and the .pro file|:
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-11T00:53:45
#
#-------------------------------------------------
QT += core serialport
QT -= gui
TARGET = serial
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
serial_intf.cpp
HEADERS += \
serial_intf.h
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-11T00:53:45
#
#-------------------------------------------------
QT += core serialport
QT -= gui
TARGET = serial
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
serial_intf.cpp
HEADERS += \
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
Bookmarks