[Development] Symbol clashes with static Qt libraries

Olivier Goffart olivier at woboq.com
Fri Aug 3 08:27:50 CEST 2018


On 2018-08-03 08:03, Martin Koller wrote:
> On Donnerstag, 2. August 2018 15:45:00 CEST Simon Hausmann wrote:
>> Hi,
>>
>>
>> Before concluding that a namespaced Qt is a terrible idea, I recommend trying out the feature.
>>
>>
>> It is intended to work transparently and not require any changes to the application, nothing like having to type MyNS::QString everywhere.
>>
>>
>> It may be problematic with forward declarations of Qt types, but the fix for that (surrounding with QT_BEGIN/END_NAMESPACE) is entirely compatible between NS and non-NS builds and does not violate the write once goal.
> 
> The correct way to use Qt classes forward declared with (and also without) a namespaced Qt build is e.g.:
> QT_FORWARD_DECLARE_CLASS(QTimer)
> 
> The problem we had with a namespaced Qt were: using external Qt based libraries, which never tried to use
> a namespaced build, did not build due to forward declarations, so I had to patch some of them.
> But then, not all external library projects liked these patches so we'd have to patch them on our own
> increasing the workload when upgrading ...
> Also, when using squish you can no longer use a prebuilt version and have to compile squish from sources
> including also the namespace AFAIR.
> 
> Eventually we could go back to non-namespaced builds, which makes your life simpler.

Ideally, we should deprecate forward declarations of Qt classes.
We should have a forwarding header, generated by syncqt, which would fordward 
declare all classes on a module.  So one would do #include <QtCoreFwd> to 
forward declare all classes in QtCore.

-- 
Olivier

Woboq - Qt services and support - https://woboq.com - https://code.woboq.org



More information about the Development mailing list