How To: QextSerialPort for Visual Studio 2010

QextSerialPort is a nice library for serial port communication. It is based on C++ cross-platform Qt framework and must have in the toolkit of DSP/embedded software developer.

I’ve spent several hours trying to compile QextSerialPort for Visual Studio 2010 + Qt 4.7.1. Here is my recipe to success.

We assume that Qt is installed in C:\Qt\4.7.1 (see How To Compile Qt 4.7 with Visual Studio 2010 for instructions).

We will build QextSerialPort in C:\Qt\qextserialport.

  1. Download and install TortoiseHG (if you don’t have it already).
  2. Download vcconvert.bat and copy it to C:\Qt.
    This script automates Visual Studio 2010 project files generation from QextSerialPort sources.
  3. Start Visual Studio 2010 Command Prompt
  4. Run following commands in it:
    cd c:\Qt
    hg clone https://qextserialport.googlecode.com/hg/ qextserialport
    vcconvert.bat
  5. Open C:\Qt\qextserialport\qextserialport.sln in Visual Studio 2010.
  6. Select qextserialportd project in Solution Explorer
  7. Alt+F7:
    General -> Target Name:
       change qextserialportd1 to qextserialportd
    Linker -> General -> Output file:
       change build\qextserialportd1.dll to build\qextserialportd.dll
  8. Choose Release configuration and repeat previous step.
  9. Compile qextserialportd project in Debug and Release modes.

Now we have ready-to-use DLLs (along with drop-in export lib files) here:

C:\Qt\qextserialport\src\build\
qextserialport.dll
qextserialport.exp
qextserialport.lib
qextserialportd.dll
qextserialportd.exp
qextserialportd.ilk
qextserialportd.lib
qextserialportd.pdb

It is good idea to copy all these files to C:\Qt\4.7.1\lib\ and DLLs only to C:\Qt\4.7.1\bin\.

You can download already compiled QextSerialPort Binaries.

Remarks
*Homepage of the QextSerialPort is http://code.google.com/p/qextserialport/. Do not use sourceforge page – it is outdated!

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00)
Loading...

12 Comments

  1. Cmessineo
    Posted August 7, 2011 at 11:06 am | #

    How would you then include the library in your Visual Studio 2010 Qt application?

    • Posted August 7, 2011 at 11:48 am | #

      By adding export library qextserialport.lib to a project and including header file to your sources.
      If this sounds gibberish, google for: adding dll to Visual C++ project or similar keywords. This is just basic knowledge.

      • Cmessineo
        Posted August 10, 2011 at 10:15 am | #

        Thanks for your help. I’m new to the Visual Studio IDE. When you say add exportt library qextserialport.lib to the project do you mean take these steps:

        Right Click project -> Click Properties ->Click Configuration Properties -> Click Linker ->Click Input -> and then add qextserialport.lib to the ‘Additional Dependencies’ list?

        Thanks for your time.

        • Posted August 10, 2011 at 10:49 am | #

          Here are steps on how to integrate QextSerialPort in Visual Studio 2010. I assume it locates in C:\Qt\qextserialport

          1. Add C:\Qt\qextserialport\src\ to Configuration Properties -> C/C++ -> Additional Include Directories.

          2. Add C:\Qt\qextserialport\src\build\ to Configuration Properties -> Linker -> Additional Library Directories

          3. Add qextserialport.lib to Configuration Properties -> Linker -> Input -> Additional Dependencies

          4. Add #include <qextserialport.h> to your source file.

          5. Compile Project. Copy qextserialport.dll from C:\Qt\qextserialport\src\build\ to the folder where compiled EXE file is. Now qextserialport.dll will be loaded automatically when program starts, so distribute it along with your application.

          These steps are valid for both Release and Debug build configurations.
          Although it is better to use qextserialportd.lib and qextserialportd.dll for Debug builds.

          Hope this helps.

          • Cmessineo
            Posted August 10, 2011 at 12:20 pm | #

            Thanks I’m getting closer but still get an error. App can’t start up. Doing something really simple (cpp file looks like below):

            #include “openserialport.h”
            #include “ui_openserialport.h”
            #include “qextserialenumerator.h”

            OpenSerialPort::OpenSerialPort(QWidget *parent) :
            QDialog(parent),
            ui(new Ui::OpenSerialPort)
            {
            ui->setupUi(this);

            QList ports = QextSerialEnumerator::getPorts();
            }

            OpenSerialPort::~OpenSerialPort()
            {
            delete ui;
            }

            When I run the app it can’t run (ugly error ‘Application was unable to start correctly’). If I take out the line : QList ports = QextSerialEnumerator::getPorts(); The app runs fine.

            I doubled check the steps you wrote out and it looks correct. Ever see this error?

          • Posted August 10, 2011 at 1:55 pm | #

            Try to copy DLL to the solution folder (where *.sln file resides)

          • Anonymous
            Posted August 11, 2011 at 3:33 am | #

            Pavel, thanks for your help on this. I went back to square one and rebuilt Qt 4.7.3 as per your instructions in another thread, and then followed the steps as you describe in this thread and no more error at application start up.

          • Posted August 11, 2011 at 9:03 am | #

            Oh, great, glad to help.

  2. Eric
    Posted March 1, 2012 at 3:39 am | #

    Thank you so much for this information. You saved me a ton of time getting this to build in MSVC++ 2008!

  3. Posted November 30, 2012 at 6:37 am | #

    This thread was very helpful saving me from building in mingw. Thanks a lot.

    BTW, Are there any updates on this thread pertaining to msvc2010? Hoping for msvc2010 support.

    Thanks and more power.

  4. Markus
    Posted March 9, 2013 at 7:01 pm | #

    Hey!

    Did you already try to compile the qextserialport for Qt5.0.1? I tried to compile it for VisualStudio2010 + Qt5.0.1 but there is always an error in VisualStudio when I want to compile for debug:
    fatal error LNK1123 error while converting into COFF. Data is invalid or damaged.

    Do you maybe know what could be wrong?

    Best regards,
    Markus Eder

Post a Reply to Pavel Holoborodko

Your email is never published nor shared.

Use native LaTeX syntax to include formulas: $ ... $, \[ ... \], etc. Do not forget to preview comment before posting.

Also you may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Subscribe without commenting