3
votes

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?

2

2 Answers

1
votes

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.

0
votes

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.