3

How do I make a static library of QextSerialPort for windows platform for use with Qt 4.8.5

I do not understand how to modify the .pro or .pri files to do this. (The .prf file keeps regenerating).

So I tried modifying the resultant .vcproj file to make a static build, and removed some of the defines, but I still get warnings like:

qextserialport.lib(qextserialport.obj) : warning LNK4006: "public: __thiscall QextSerialPort::QextSerialPort(class QString const &,enum QextSerialPort::QueryMode,class QObject *)" (??0QextSerialPort@@QAE@ABVQString@@W4QueryMode@0@PAVQObject@@@Z) already defined in qextserialportd1.lib(qextserialportd1.dll); second definition ignored

and at run time get "System Error: The program can't start because qextserailportd1.dll is missing from your computer". Which of course is true because I am trying to make a static build using a .lib

So how do I correctly do a static build?

Nejat
  • 31,784
  • 12
  • 106
  • 138
David Casper
  • 394
  • 2
  • 9

2 Answers2

1

There is no need to build a static library of QextSerialPort. You can simply use the source code in your application. Just include it's .pri file in your .pro file :

include(Path/To/qextserialport.pri)

Or copy QextSerialPort source code from src directory to your application directory and add the following line to your project file :

include(qextserialport.pri)

Now you can include the header file :

#include "qextserialport.h"

And use the library :

QextSerialPort * port = new QextSerialPort("COM1");
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
port->open();

Without any need to linking the library or putting the dll for deployment.

Nejat
  • 31,784
  • 12
  • 106
  • 138
0

Thanks Nejat for your response. Very clear.

Also, for those following in my footsteps, it was a case of read-the-manual for me. The answer is in: https://code.google.com/p/qextserialport/wiki/QextSerialPort_1_2_RC

It plainly says to add CONFIG += qesp_static

to the .pro file. This works too.

David Casper
  • 394
  • 2
  • 9
  • 1
    If you think Nejat's answer is helpful and it solves your problem, please consider **accepting** the answer (by clicking "V" under the score). On the contrary, if you think your own answer is better, you may accept it instead. Unless all current answers are not good enough, you should accept the best answer so that people would consider your problem solved and other people who have the same problem will take the accepted answer as the standard solution. – Tay2510 Jan 06 '15 at 03:38