Skip to content

Fix build with `QT_USE_PROTECTED_VISIBILITY`

Dāvis Mosāns requested to merge davism/konsole:export into master

On ArchLinux Qt6 is configured with

#define QT_VISIBILITY_AVAILABLE
#define QT_USE_PROTECTED_VISIBILITY

And that will cause Q_DECL_EXPORT to resolve to (see qcompilerdetection.h)

__attribute__((visibility("protected")))

which will prevent KonsoleSettings being usable from other modules.

Without this change build fails with

[ 84%] Linking CXX shared module ../bin/konsolepart.so
/usr/bin/ld: CMakeFiles/konsolepart.dir/Part.cpp.o: in function `Konsole::Part::showManageProfilesDialog(QWidget*)':
konsole/src/Part.cpp:303: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: ../bin/konsolepart.so: protected symbol `_ZN7Konsole15KonsoleSettings4selfEv' isn't defined

[ 84%] Linking CXX shared library ../bin/libkonsoleapp.so
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o: in function `Konsole::KonsoleSettings::showWindowTitleOnTitleBar()':
/usr/src/debug/konsole-git/build/src/KonsoleSettings.h:113: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o: in function `Konsole::KonsoleSettings::removeWindowTitleBarAndFrame()':
/usr/src/debug/konsole-git/build/src/KonsoleSettings.h:41: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o: in function `Konsole::KonsoleSettings::allowMenuAccelerators()':
/usr/src/debug/konsole-git/build/src/KonsoleSettings.h:149: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o: in function `Konsole::KonsoleSettings::newTabBehavior()':
/usr/src/debug/konsole-git/build/src/KonsoleSettings.h:941: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o: in function `Konsole::MainWindow::MainWindow()':
/mnt/Dati/Git/KDE/konsole/src/MainWindow.cpp:130: undefined reference to `Konsole::KonsoleSettings::self()'
/usr/bin/ld: CMakeFiles/konsoleapp.dir/MainWindow.cpp.o:konsole/src/MainWindow.cpp:130: more undefinedreferences to `Konsole::KonsoleSettings::self()' follow
/usr/bin/ld: ../bin/libkonsoleapp.so.23.07.70: protected symbol `_ZN7Konsole15KonsoleSettings4selfEv' isn't defined

Not sure if there's better way to fix it but this works only it does give bunch of warnings

In file included from konsole/src/Part.cpp:26:
konsole/build/src/KonsoleSettings.h:12:33: warning: ‘weak’ attribute does not apply to types[-Wattributes]
12 | class Q_DECL_EXPORT_OVERRIDABLE KonsoleSettings : public KConfigSkeleton
|                                 ^~~~~~~~~~~~~~~

Merge request reports