Recognizing session type failed with Qt 5.12.8
Trying to link library with another project gives:
undefined reference to `QX11Info::isPlatformX11()'
I've noticed that in doc it shall be included in Qt 5.2: https://doc.qt.io/qt-5/qx11info.html#isPlatformX11
but it looks like it is not. It was included in following commit: https://github.com/qt/qtbase/commit/edceff30b4093e2bef6e80c7552edf595134f351 which precedes: v6.2.0-alpha1, v6.3.0-alpha1, v6.4.0-beta1
therefore check shall looks like:
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
return qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
#else
char *v = getenv("XDG_SESSION_TYPE");
return (v == NULL || strcasecmp(v, "x11") == 0);
#endif
Similar issue can be recognized with:
undefined reference to `QX11Info::display()'
but I haven't take a look closely on it yet.
but it looks like it is not. It was included in following commit:
It's because Qt removed it in 6.0 and re-introduced it in 6.2.
Perhaps you built without QtExtras? Because I have these files:
usr/
usr/include/
usr/include/qt/
usr/include/qt/QtX11Extras/
usr/include/qt/QtX11Extras/QX11Info
usr/include/qt/QtX11Extras/QtX11Extras
usr/include/qt/QtX11Extras/QtX11ExtrasDepends
usr/include/qt/QtX11Extras/QtX11ExtrasVersion
usr/include/qt/QtX11Extras/qtx11extrasglobal.h
usr/include/qt/QtX11Extras/qtx11extrasversion.h
usr/include/qt/QtX11Extras/qx11info_x11.h
usr/lib/
usr/lib/cmake/
usr/lib/cmake/Qt5X11Extras/
usr/lib/cmake/Qt5X11Extras/Qt5X11ExtrasConfig.cmake
usr/lib/cmake/Qt5X11Extras/Qt5X11ExtrasConfigVersion.cmake
usr/lib/libQt5X11Extras.prl
usr/lib/libQt5X11Extras.so
usr/lib/libQt5X11Extras.so.5
usr/lib/libQt5X11Extras.so.5.15
usr/lib/libQt5X11Extras.so.5.15.5
usr/lib/pkgconfig/
usr/lib/pkgconfig/Qt5X11Extras.pc
usr/lib/qt/
usr/lib/qt/mkspecs/
usr/lib/qt/mkspecs/modules/
usr/lib/qt/mkspecs/modules/qt_lib_x11extras.pri
usr/lib/qt/mkspecs/modules/qt_lib_x11extras_private.pri
usr/share/
usr/share/licenses/
usr/share/licenses/qt5-x11extras
So looks like you have it too?
That's right together with dev headers. It should just work, but mu point is that there is no method called isPlatformX11 in QtX11extrass lib itself until 6.2
That's strange. Because I use isPlatformX11() with Qt5 on my machine for several years for sure. I believe that something wrong with linkage on your machine.
So QHotkey should link with X11Extras for Qt5?
No, if a library depends on something - CMake should propagate it dependency.
I believe we link it here:
https://github.com/Skycoder42/QHotkey/blob/34777f2e91b72cdc62a415975cc3ec53475ed022/CMakeLists.txt#L62-L66
But it doesn't work for you?
links to target "Qt5::X11Extras" but the target was not
So CMake cannot find Qt5::X11Extras on your system. Unfortunately, something wrong with your system configuration.
The point is unless I add: find_package(Qt5X11Extras REQUIRED) to my cmake I am getting the error like at the beginning.
Can't help you here. It should just work.