[Development] GCC-built Qt 5.6 can't be used with Clang
Stephen Kelly
steveire at gmail.com
Sat Feb 20 11:33:21 CET 2016
Hello,
I built Qt dev branch with GCC.
Then I tried to use it to build any trivial shared library with Clang:
stephen at hal:/tmp/qmake$ make CXX=clang++ LINK=clang++ -B
makeobj[0]: Entering directory `/tmp/qmake'
/home/stephen/dev/prefix/qtbase/bin/qmake -o Makefile qmake.pro
clang++ -c -pipe -g -std=gnu++11 -std=c++11 -Wall -W -D_REENTRANT -fPIC -
DQT_CORE_LIB -I. -I/home/stephen/dev/prefix/qtbase/include -
I/home/stephen/dev/prefix/qtbase/include/QtCore -I. -
I/home/stephen/dev/prefix/qtbase/mkspecs/linux-g++ -o thelib.o thelib.cpp
rm -f libthelib.so.1.0.0 libthelib.so libthelib.so.1 libthelib.so.1.0
clang++ -Wl,-rpath,/home/stephen/dev/prefix/qtbase/lib -shared -Wl,-
soname,libthelib.so.1 -o libthelib.so.1.0.0 thelib.o -
L/home/stephen/dev/prefix/qtbase/lib -lQt5Core -lpthread
/usr/bin/ld: thelib.o: relocation R_X86_64_32 against `qt_version_tag' can
not be used when making a shared object; recompile with -fPIC
thelib.o: error adding symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
Makefile:147: recipe for target 'libthelib.so.1.0.0' failed
make: *** [libthelib.so.1.0.0] Error 1
makeobj[0]: Leaving directory `/tmp/qmake'
1) The qt_version_tag is new in Qt 5.6, so I assume this happens with that
Qt version too.
2) If I compile with -DQT_NO_VERSION_TAGGING, then the link succeeds.
Reading the preprocessor code in qtversiontagging, I can see why.
3) Is it deliberate that GCC-built Qt can no longer be used with Clang?
I haven't seen mailing list discussion confirming that.
4) If that should still be possible, are clients expected to add their own
define of -DQT_NO_VERSION_TAGGING?
It could be added to the qmake/cmake files if so for these mixing
conditions.
Thanks,
Steve.
More information about the Development
mailing list