Page MenuHome GnuPG

gpgme fails to "build a simple Qt program"
Closed, ResolvedPublic

Description

I'm building gpgme git master with --enable-maintainer-mode --enable-languages=cpp,qt6
(on top of a Qt 6.5.3 I built myself), and I'm getting the error "checking whether a simple Qt program can be built... no"

config.log says:

configure:21152: checking whether a simple Qt program can be built
configure:21163: g++ -o conftest -g -O2 -I/d/qt/6/inst/include/QtCore
-I/d/qt/6/inst/include -DQT_CORE_LIB -I/d/qt/6/inst/mkspecs/linux-g++  
conftest.cpp -L/d/qt/6/inst/lib -lQt6Core  >&5 In file included from
/d/qt/6/inst/include/QtCore/qglobal.h:34,
from /d/qt/6/inst/include/QtCore/qcoreapplication.h:7,
from /d/qt/6/inst/include/QtCore/QCoreApplication:1,
from conftest.cpp:47:
/d/qt/6/inst/include/QtCore/qcompilerdetection.h:1249:4: error: #error "You
must build your code with position independent code if Qt was configured
with -reduce-relocations. " "Compile your code with -fPIC (and not with
-fPIE)." 1249 | #  error "You must build your code with position
independent code if Qt was configured with -reduce-relocations. "\

Exact build procedure:
./autogen.sh && mkdir build && cd build && ../configure --enable-maintainer-mode --enable-languages=cpp,qt6 && make

If I git revert 3e6485620816c9097f98cbe4fdb82a4683918a63, it all builds fine again.
Ingo suggested I create a bug report here.

Related Objects

Event Timeline

aheinecke triaged this task as Normal priority.
aheinecke added projects: gpgme, Restricted Project.
aheinecke added a subscriber: aheinecke.

Thanks for creating the task.

The problem was that our test always added -fPIC and that created errors with distros where this then created errors. So it works for you with the revert because you need -fPIC. I wonder why we can't just get the CFLAGS from pkg-config instead of doing this indirect checking.

I think we could solve this by using the same check for no-direct-extern-access also to check for reduce-relocations and then add -fPIC. Ingo can you look into this, I don't even have a Qt6 build to test against currently and the qt6.m4 was so far your work. :)

ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Oct 30 2023, 8:56 AM

Small correction: On my/our system (Tumbleweed) the test without -fPIC always succeeded, so that -fPIC was never added. That's why I removed this useless test which, as it turns out, wasn't useless on your distro (@dfaure-kdab Which distro are you using?).

We cannot get the CFLAGS from pkg-config because Qt's pkg-config doesn't provide this information.

Yes, I think to proper solution is using a similar approach as for no-direct-extern-access (which is very similar to what we do for Qt 5 except that in Qt 5 we could get the information directly from pkg-config).

ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

Should work now. Please test if the auto-detection works. (Tumbleweed builds Qt 6 without "reduce-relocations", so that I cannot check it on my system.)