Results 1 to 6 of 6

Thread: Problem in QExtserialport program.

  1. #1
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem in QExtserialport program.

    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:n_CloseportButton_clicked()
    {
    port->close();
    qDebug("is open: %d", port->isOpen());
    }

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

    void RS232_Receive:n_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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in QExtserialport program.

    Add __declspec(dllexport) after word "class" and before the actual class name in QExtSerialPort and QExtSerialBase classes and rebuild the library.

  3. #3
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in QExtserialport program.

    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
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in QExtserialport program.

    Looks like you have a white space in your path and some tools don't like it. Search the forum for similar issues.

  5. #5
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in QExtserialport program.

    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.

  6. #6
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in QExtserialport program.

    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

Similar Threads

  1. Replies: 6
    Last Post: 22nd November 2016, 13:57
  2. QProcess problem (Main program hangs)
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2007, 09:26
  3. problem in doing database program
    By wei243 in forum Qt Programming
    Replies: 0
    Last Post: 4th April 2007, 12:01
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Console Program Problem
    By ball in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2006, 09:05

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.