Akonadi dependent projects fail to build due to use of both system and locally installed headers
[ 4%] Building CXX object src/libimportwizard/CMakeFiles/KPimImportWizard.dir/abstractaddressbook.cpp.o
In file included from /usr/include/KF5/AkonadiCore/collection.h:10,
from /kde/usr/include/KF5/AkonadiWidgets/collectiondialog.h:11,
from /kde/usr/include/KF5/AkonadiWidgets/CollectionDialog:1,
from /home/phd/kde/src/pim/akonadi-import-wizard/src/libimportwizard/abstractaddressbook.cpp:12:
/usr/include/KF5/AkonadiCore/attribute.h:124:26: error: redefinition of ‘class Akonadi::Attribute’
124 | class AKONADICORE_EXPORT Attribute // clazy:exclude=copyable-polymorphic
| ^~~~~~~~~
In file included from /kde/usr/include/KF5/AkonadiCore/collection.h:10,
from /kde/usr/include/KF5/AkonadiCore/Collection:1,
from /home/phd/kde/src/pim/akonadi-import-wizard/src/libimportwizard/abstractaddressbook.h:11,
from /home/phd/kde/src/pim/akonadi-import-wizard/src/libimportwizard/abstractaddressbook.cpp:6:
/kde/usr/include/KF5/AkonadiCore/attribute.h:124:26: note: previous definition of ‘class Akonadi::Attribute’
124 | class AKONADICORE_EXPORT Attribute // clazy:exclude=copyable-polymorphic
| ^~~~~~~~~
This class is defined both in system-wide header:
/usr/include/KF5/AkonadiCore/attribute.h:124:26
and in the one installed locally (by the kdesrc-build
script):
/kde/usr/include/KF5/AkonadiCore/attribute.h:124:26
Somehow the toolchain uses both of those files!
And since there are no header guards in those files, but only #pragma once
, both get included.
Still the locally installed headers should be preferred and only one should ever be used (consistently).
Many such errors.
Those errors are common to several KDE projects (kmailtransport, messagelib, calendarsupport, incidenceeditor, kalarmcal, akonadi-import-wizard, akonadi-calendar-tools, akregator, kaddressbook, kdepim-addons, korganizer), which all fail to build because of this issue.
The problem is always only about Akonadi headers (no other headers seem to cause similar issues).