Qt-interest Archive, August 2006
[qt-3] qt and dll
Message 1 in thread
Hello!
I have qt lib and app win32/x11 projects. One exports classes, another imports.
I've tried staticlib and it works fine. Now I want to make dll.
1. lib project
.pro file:
TEMPLATE = lib
CONFIG += dll
and so on ..
only one .h file:
class Q_EXPORT QMyClass
{
etc, etc, etc
};
When I build it i get "inconsistent linkage warnings".
2. app project:
.pro file:
TEMPLATE = app
INCLUDEPATH += <path to lib's headers>
LIBPATH += <path to lib's target>
unix {
LIBS *= -<lib name>
}
win32 {
LIBS *= delayimp.lib
QMAKE_LFLAGS += /DELAYLOAD:<lib name>
}
source code: here i just include needed .h and use QMyClass.
Here I get "unresolved symbol error".
I've looked through qt project and all qt's classes exports this way.
Obviously, I miss something .. help me find what I miss.
--
[ signature omitted ]
Message 2 in thread
Do not use Q_EXPORT - that's Qt's macro. You have to use your own.
Volker
"Dmitry Teslenko" <dmitryqt@xxxxxxxxx> wrote in message
news:4483888f0608300714qd5a5bfo95717c5fe98db4b1@xxxxxxxxxxxxxxxxx
> Hello!
> I have qt lib and app win32/x11 projects. One exports classes, another
> imports.
> I've tried staticlib and it works fine. Now I want to make dll.
>
> 1. lib project
> .pro file:
>
> TEMPLATE = lib
> CONFIG += dll
>
> and so on ..
>
> only one .h file:
> class Q_EXPORT QMyClass
> {
> etc, etc, etc
> };
>
> When I build it i get "inconsistent linkage warnings".
>
> 2. app project:
> .pro file:
>
> TEMPLATE = app
> INCLUDEPATH += <path to lib's headers>
> LIBPATH += <path to lib's target>
>
> unix {
> LIBS *= -<lib name>
> }
>
> win32 {
> LIBS *= delayimp.lib
> QMAKE_LFLAGS += /DELAYLOAD:<lib name>
> }
>
> source code: here i just include needed .h and use QMyClass.
>
> Here I get "unresolved symbol error".
> I've looked through qt project and all qt's classes exports this way.
> Obviously, I miss something .. help me find what I miss.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 3 in thread
On 30/08/06, Volker Hilsheimer <unwatched@xxxxxxx> wrote:
> Do not use Q_EXPORT - that's Qt's macro. You have to use your own.
Ok, I think I'm starting to understand it :)
I make this macro:
#ifdef Q_WS_WIN
# ifdef QTS_MAKEFM
# define QTS_EXPORT __declspec(dllexport)
# elif QTS_FM
# define QTS_EXPORT __declspec(dllimport)
# else
# define QTS_EXPORT
# endif
#else
# define QTS_EXPORT
#endif
and add
DEFINES += QTS_MAKEFM into lib's .pro
and
DEFINES += QTS_FM into app's project.
So, when I'm building lib i get dllexport in my .h's and when I'm
building app i get dllimport there.
Warnings about "inconsistence" gone, but I still get "unresolved
symbol" in my app project.
--
[ signature omitted ]
Message 4 in thread
> -----Original Message-----
> From: Dmitry Teslenko [mailto:dmitryqt@xxxxxxxxx]
> Sent: Wednesday, August 30, 2006 9:04 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: [qt-3] qt and dll
>
> On 30/08/06, Volker Hilsheimer <unwatched@xxxxxxx> wrote:
> > Do not use Q_EXPORT - that's Qt's macro. You have to use your own.
>
> Ok, I think I'm starting to understand it :)
>
> I make this macro:
>
> #ifdef Q_WS_WIN
> # ifdef QTS_MAKEFM
> # define QTS_EXPORT __declspec(dllexport)
> # elif QTS_FM
> # define QTS_EXPORT __declspec(dllimport)
> # else
> # define QTS_EXPORT
> # endif
> #else
> # define QTS_EXPORT
> #endif
>
> and add
> DEFINES += QTS_MAKEFM into lib's .pro
> and
> DEFINES += QTS_FM into app's project.
> So, when I'm building lib i get dllexport in my .h's and when I'm
> building app i get dllimport there.
>
> Warnings about "inconsistence" gone, but I still get "unresolved
> symbol" in my app project.
>
Last step... In the apps .pro, add a LIBS += -l..... for the dlls .lib
Scott
--
[ signature omitted ]
Message 5 in thread
> Last step... In the apps .pro, add a LIBS += -l..... for the dlls .lib
>
> Scott
Aaaand it works!!! Thanks! Thanks! Thanks!
--
[ signature omitted ]