PDA

View Full Version : Problem in QExtserialport program.



dheeraj
30th May 2008, 08:28
Hi friends ,
I wanted to send some random data which is generated from computer one and sent on serial port to computer two. I used Qextserialport for it. But there seems to be a problem. I get two linker error which i am not able to figure out what is wrong.



moc_rs232_receive.cpp
Linking...
rs232_receive.obj : error LNK2019: unresolved external symbol "public: __thiscall QextSerialPort::QextSerialPort(class QString const &,enum QextSerialBase::QueryMode)" (??0QextSerialPort@@QAE@ABVQString@@W4QueryMode@Qe xtSerialBase@@@Z) referenced in function "public: __thiscall RS232_Receive::RS232_Receive(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0RS232_Receive@@QAE@PAVQWidget@@V?$QFlags@W4Win dowType@Qt@@@@@Z)
F:\Cofiguration Management\RS232_Receive\RS232_Receive\Debug\RS232 _Receive.exe : fatal error LNK1120: 1 unresolved externals
RS232_Receive - 2 error(s), 0 warning(s)


This is the cpp file.


#include "rs232_receive.h"
#include <qextserialport.h>
#include <QPushButton>


RS232_Receive::RS232_Receive(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
//modify the port settings on your own
port = new QextSerialPort("COM1");
port->setBaudRate(BAUD19200);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_2);
//set timeouts to 500 ms
port->setTimeout(500);

qDebug("isOpen : %d", port->isOpen());
}

RS232_Receive::~RS232_Receive()
{
delete port;
port = NULL;
}

void RS232_Receive::on_CloseportButton_clicked()
{
port->close();
qDebug("is open: %d", port->isOpen());
}

void RS232_Receive::on_openportButton_clicked()
{
port->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
qDebug("is open: %d", port->isOpen());
}

void RS232_Receive::on_ReceivengportButton_clicked()
{
char buff[1024];
int numBytes;

numBytes = port->bytesAvailable();
if(numBytes > 1024)
numBytes = 1024;

int i = port->read(buff, numBytes);
if (i != -1)
buff[i] = '\0';
else
buff[0] = '\0';
QString msg = buff;

received_msg->append(msg);
received_msg->ensureCursorVisible();
qDebug("bytes available: %d", numBytes);
qDebug("received: %d", i);
}


I cross checked this program with the qextserialport example but i din find any thing wrong. I am not able to remove these errors.

Thank You

wysota
30th May 2008, 10:50
Add __declspec(dllexport) after word "class" and before the actual class name in QExtSerialPort and QExtSerialBase classes and rebuild the library.

dheeraj
30th May 2008, 13:13
Hi Wysota i did what you told but i get a new error


------ Build started: Project: RS232_Receive, Configuration: Debug Win32 ------
Uic'ing c:\qextserialport-1.2win-alpha\qextserialport-1.2win-alpha\examples\RS232_Receive\RS232_Receive\rs232_r eceive.ui...
Moc'ing rs232_receive.h...
Compiling...
moc_rs232_receive.cpp
rs232_receive.cpp
main.cpp
Generating Code...
Linking...
LINK : fatal error LNK1181: cannot open input file 'Files\Microsoft.obj'


Also i had another doubt Wysota
I am actually trying to retrive data from serial port and dump it into the Sqlite db. Can you pls tell me how i need to dump the retrived data into the db. I have attached the project file pls check for where i am going wrong.


Thank You

wysota
30th May 2008, 16:00
Looks like you have a white space in your path and some tools don't like it. Search the forum for similar issues.

pherthyl
30th May 2008, 16:25
Yes, make sure that none of your linker paths (like LIBS += -L"some path") have spaces in them. It won't work. That Files\Microsoft.obj is from a path in Program Files. Move the lib somewhere else without spaces.

dheeraj
31st May 2008, 10:24
Hi wysota and pherthyl thanks for the reply. I managed to remove the errors . I created a pro file and added the configuration settings. And all the errors vanished.

:)

Thank You