[Qt-interest] Link errors with static Qt

Urs Dönni urs_doenni at gmx.ch
Tue Mar 31 14:37:08 CEST 2009


Thanks for the answers, I figured out the problem now:
I was using the same *.vcproj that I had used to link against the shared Qt,
and that had the symbol QT_DLL defined, which caused the linker errors.

Urs

On Tue, Mar 31, 2009 at 11:20 AM, David Ching <dc at dcsoft.com> wrote:

> > From: Juan D Guzman <lostinthecode at googlemail.com>
> > Subject: Re: [Qt-interest] Link errors with static Qt
> >
> > Urs D?nni wrote:
> > > Hi,
> > >
> > > I'm using VisualStudio 2005 and Qt 4.5. I have a problem when using
> > > the static version of Qt. The project compiles, links and runs fine
> > > when using the shared version of Qt (linking QtOpenGL4.lib,
> > QtGui4.lib
> > > and QtCore4.lib).
> > >
> > > Then I wanted to use static Qt, so I compiled Qt using
> > > > configure -static
> > > > nmake
> > >
> > > I link QtOpenGL.lib, QtGui.lib and QtCore.lib, and I get several link
> > > errors (see below). As far as I can tell, all the function that could
> > > not be linked should be in the libs I link against (and when I don't
> > > link against one of those, I get hundreds of link errors). Does
> > > anybody have an idea why those functions are not found and what I can
> > > do about it?
> > > ...
> > > Error messages:
> > >
> > > marchingsource.obj : error LNK2001: unresolved external symbol
> > > "__declspec(dllimport) public: static class QString __cdecl
> > > QFileDialog::getSaveFileName(class QWidget *,class QString const
> > > &,class QString const &,class QString const &,class QString *,class
> > > QFlags<enum QFileDialog::Option>)"
> > >
> > have you built static versions of the libraries?
> >
>
> The unresolved symbols all have __declspec(dllimport) meaning the caller
> (e.g. marchingsource.cpp) expects them to be exported from a DLL, but since
> it is a static library, they are not exported.  Something is wrong with the
> definition of Q_GUI_EXPORT, since the function is declared like this in
> <qfiledialog.h>:
>
> class Q_GUI_EXPORT QFileDialog : public QDialog
> {
>    ...
>    static QString getSaveFileName(QWidget *parent = 0,
>                                   const QString &caption = QString(),
>                                   const QString &dir = QString(),
>                                   const QString &filter = QString(),
>                                   QString *selectedFilter = 0,
>                                   Options options = 0);
> }
>
>
> -- David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090331/03fea490/attachment.html 


More information about the Qt-interest-old mailing list