erewalk / qextserialport

Automatically exported from code.google.com/p/qextserialport
Other
0 stars 0 forks source link

error building Qextserialport lib as shared or static dll #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello all,
i'm having the following issue trying to build qextserialport lib on win32 
(winXP): i've downloaded the latest version of the library and created a 
CFileList file to compile the library (see attached doc).

When i'm trying to build the dll, i get a lot of warnings and the following 
type of errors:
error LNK2019: unresolved external symbol "__declspec(dllimport)const 
QextSerialPort::`vftable'"

when i'm trying to build the static lib, i only get warnings, such as:
warning C4273: 'QextSerialPort::QextSerialPort' : inconsistent DLL linkage 
(although i'm building the lib as a shared library !)

If I then try to use the lib with one of the provided examples, I get a lot of 
linker errors...

Would anyone have insights on what could be wrong ?
For the static build, I tried to apply the patches suggested in issue 79:
http://code.google.com/p/qextserialport/issues/detail?id=70
But it did not solve my problem...

Original issue reported on code.google.com by sandrine...@gmail.com on 11 Aug 2010 at 10:08

Attachments:

GoogleCodeExporter commented 9 years ago
Hello again,

I found an error in my CMakeLists.txt with the patch suggested in issue 70  
(replace -D_QEXTSERIALPORT_STATICLIB by -DQEXTSERIALPORT_STATICLIB) and was 
able to compile the static Qextserialport (precision with respect to the first 
post: i'm using win32 with VisualStudio2008). 

However, i still have a linker error when trying to build a simple example: 

#include <QApplication>
#include <qextserialenumerator.h>
#include <qextserialport.h>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
    return app.exec();
}

I get the following unresolved external symbol:

"__declspec(dllimport) public: static class QList<struct QextPortInfo> __cdecl 
QextSerialEnumerator::getPorts(void)"

Same thing when I try to open a port, with a project where i just try to create 
a new port (QextSerialPort * port1 = new QextSerialPort("COM1", 
QextSerialPort::EventDriven);):

unresolved external symbol "public: virtual struct QMetaObject const * 
__thiscall QextSerialPort::metaObject(void)const "

In my CMakeList.txt i have included the follwing windows libraries when 
building the lib since it was suggested in some posts: 

setupapi
advapi32 
user32
shell32

Original comment by sandrine...@gmail.com on 11 Aug 2010 at 1:11

GoogleCodeExporter commented 9 years ago
I can confirm the same issue here, when building "enumerator" example and using 
QextSerialPort as a static lib.

>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) 
public: static class QList<struct QextPortInfo> __cdecl 
QextSerialEnumerator::getPorts(void)" 
(__imp_?getPorts@QextSerialEnumerator@@SA?AV?$QList@UQextPortInfo@@@@XZ) 
referenced in function _main

While symbol seems to be defined in the lib ... (I've included 
qextserialenumerator_win.cpp into the lib)

MSVC 2010 win64

Original comment by dstep...@gmail.com on 16 Nov 2011 at 10:02

GoogleCodeExporter commented 9 years ago
The problem is solved for me by modofying the following line in 
"qextserialenumerator.h"

ln 96> class QEXTSERIALPORT_EXPORT QextSerialEnumerator : public QObject
TO> class QextSerialEnumerator : public QObject

So, perhaps, the macro QEXTSERIALPORT_EXPORT need to be changed ...

Original comment by dstep...@gmail.com on 16 Nov 2011 at 10:16

GoogleCodeExporter commented 9 years ago

Original comment by dbzhang...@gmail.com on 16 Mar 2012 at 8:49