hi, with mingw, when qwt is compiled as a shared library, client code emits these warnings:
/usr/x86_64-w64-mingw32/include/qwt/qwt_interval.h:112:8: error: ‘QwtInterval::QwtInterval()’ redeclared without dllimport attribute after being referenced with dll linkage [-Werror]
112 | inline QwtInterval::QwtInterval()
the problem is some class methods are declared non-inline, eg:
class QWT_EXPORT QwtInterval
{
public:
QwtInterval::QwtInterval()
...
};
but then redefined as inline:
inline QwtInterval::QwtInterval()
: m_minValue( 0.0 )
, m_maxValue( -1.0 )
, m_borderFlags( IncludeBorders )
{
}
but on win32 targets QWT_EXPORT expands to dllimport/dllexport which conflict with inline visibility attribute
there are several solutions to this:
while 1 is the minimal fix, 2 would be more invasive but imho would be cleaner to reduce the client code compilation and clearly mark the interface separation
which option do you prefer ? I can propose a patch if you want
Anonymous
The inline keyword is not used in any of the Qwt class declarations - so the situation you are describing can be found in many Qwt headers.
However - it is ike this since 20 years and Qwt has been used in many projects using mingw. So there must be something special about your project ?
I had a look at the Qt headers and most of the inlined methods are indeed declared as inline in the class declaration. However you also find something like QSize::QSize, were the inline keyword is for the implementation only ( not 100% comparable with QwtIntervall::QwtInterval as it has the constexpr keyword )
yes, as described it could be more than QwtInterval; happens with QwtPoint3D too, but maybe other classes
possible explanations to why is has not been adressed yet is:
j
minimal reproducer, compile with QWT_DLL on mingw/gcc16 with QWT_DLL:
Last edit: jschueller 2026-09-07
As mentioned before: Qwt is used in so many projects for so long that I can hardly imagine that you are the first one using DLLs with mingw on Windows.
So lets have a look how the compiler is used in your build process:
1) How do you build Qwt - using the official qmake project files ?
2) How do you build your application ?
3) What Qt version are you using ?
PS: I'm not using Windows myself - actually I do not have a Windows box at all here.
I'm using mingw-w64-qwt 6.3.0 from archlinux, with latest qt6 6.11.x, here is a minimal reproducer that can be run from linux using docker:
https://gist.github.com/jschueller/bf45e0787a44d359b8b12cd18306bb1d
After looking a second time to your initial bug report I noticed, that it is "only" about a compiler warning, that is treated as error because you actively enabled -Werror - right ?
Could you please build without -Werror and show the line with the warning. Then we can see the specific compiler flag that is responsible for the warning ?
you are right my CMakeLists added -Werror, but even -Werror we cannot see any compiler flag id
the explanation is that this is a mingw backend warning (i386/winnt.c) and not a -W* option
so we have no -Wno-... to silence it either:
So I believe the fix is still to avoid dllimport out-of-line inlines as proposed initially, either to declare them inline, or merge declaration and definition as inline, or move definition to .cpp
O.k. now it is understandable, that nobody complained before and I would consider it less urgent than a compiler error. However Qwt headers should not be the reason for warnings when compiling application code and these warnings have to be be avoided - like a couple of deprecation warnings that started to happen with recent Qt versions.
Moving the implementation to the cpp file means that there is no inlining anymore. I also dislike this solution because the next Qwt release will drop Qt4.x ( nobody needs it anymore ) and the code can rely on more modern c++ versions using constexpr etc.
Moving the implementation into the class declaration makes reading the class API harder, that's why I do not like this solution either.
So my preferred solutions is to duplicate the inline keyword before the method declaration. This might be the expected solution as this is what is done in Qt headers. Will do the fixes the next time I'm working on Qwt.
great, thanks a lot