[Interest] Problem creating a dll that loads static Qt libraries (in mingw) -> final chapter
erick oliveira da silva
eosilva2000 at ig.com.br
Thu Jan 19 13:51:03 CET 2012
Hi Folks,
Just a last update about my problem:
1) With mingw at windows, I can't build a shared library exporting a
function, using a Qt library statically built ( *-static* option in *configure
*). It is strange: if I export a class, the .dll is built suscessfully, and
works. If I write and export just a c++ function that contains/uses Qt
classes, I get "undefined reference" when I try to link the shared library.
2) The same .pro file and functions build a shared library susccessfully in
linux (gcc), and at Windows with MSVC compiler.
3) It works in mingw only if I use Qt dinamic libraries(-*shared *option in
configure).
I think it is a Qt bug.
I am using Qt 4.7.4 commercial and compiler gcc 4.4.0 from mingw.
To test it, I just created and exported a function that creates a QString
object and prints its content in the screen using "printf()".
Best Regards,
Erick
---------- Forwarded message ----------
From: erick oliveira da silva <eosilva2000 at ig.com.br>
Date: 2012/1/17
Subject: Re: [Interest] Problem creating a dll that uses Qt (mingw)
To: interest at qt-project.org
Thanks Lincoln,
I installed again mingw and Qt and nothing changes.
I think my problem is a bug from Qt 4.7.4.
Best Regards,
Erick
2012/1/17 Lincoln Ramsay <lincoln.ramsay at nokia.com>
> On 01/17/2012 04:54 AM, ext Till Oliver Knoll wrote:
> > I don't know what the *= operator is supposed to do, even though I think
> > it exists.
>
> It means "add these values to this variable unless they are already
> there". In pseudocode:
>
> for each value (list) {
> if (!variable.contains(value))
> variable.append(value)
> }
>
> Or for an example:
>
> FOO = bar # FOO contains (bar)
> FOO += bar # FOO contains (bar, bar)
> FOO *= foo bar # FOO contains (bar, bar, foo)
>
> > On another note, Qt provides some "cross-platform" macros which expands
> > to that __declspec stuff on Windows and to "nothing" on most other
> > platforms. Can't remember its name right now, but I thing it's defined
> > in the global namespace in qt.h or qt_global.h or something...
>
> What you want is something like this (replace XXX with your library's
> name):
>
> #include <QtCore/qglobal.h>
>
> #if defined(Q_OS_WIN)
> # if defined(QT_NODLL)
> # undef QT_MAKEDLL
> # undef QT_DLL
> # elif defined(QT_MAKEDLL)
> # if defined(QT_DLL)
> # undef QT_DLL
> # endif
> # if defined(QT_BUILD_XXX_LIB)
> # define Q_XXX_EXPORT Q_DECL_EXPORT
> # else
> # define Q_XXX_EXPORT Q_DECL_IMPORT
> # endif
> # elif defined(QT_DLL)
> # define Q_XXX_EXPORT Q_DECL_IMPORT
> # endif
> #endif
>
> #if !defined(Q_XXX_EXPORT)
> # if defined(QT_SHARED)
> # define Q_XXX_EXPORT Q_DECL_EXPORT
> # else
> # define Q_XXX_EXPORT
> # endif
> #endif
>
>
>
> Then you define QT_BUILD_XXX_LIB when building your library.
>
>
> --
> Lincoln Ramsay - Senior Software Engineer
> Qt Development Frameworks, Nokia - http://qt.nokia.com/
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120119/b6e44b1e/attachment.html>
More information about the Interest
mailing list