[Qt-interest] Link errors with static Qt

David Ching dc at dcsoft.com
Tue Mar 31 11:20:28 CEST 2009


> 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




More information about the Qt-interest-old mailing list