[Development] Qt-5.1, qglobal.h and PIC detection

Christian Gagneraud chgans at gna.org
Wed Nov 6 00:17:56 CET 2013


Hi,

I'm using CLang build-analize tool, and when I switched from Qt 4.8 to 
Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, 
basically the code is built with -fPIC, but CLang doesn't define a PIC 
macro, so the build fails due to a check in qglobal.h (see details below).

Is it possible to use CLang 3.2 with Qt 5.1 on Linux, or do I need to 
use amore recent verion of CLang or maybe wait for Qt 5.2?

Any hint appreciated,
Chris

# Clang version on Ubunutu 13.04:
$  clang --version
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on 
LLVM 3.2)
Target: i386-pc-linux-gnu
Thread model: posix

# No PIC macros defined by CLang:
$ clang -dM -E -x c /dev/null |grep -i 'PIC\|PIE\|ELF'
#define __ELF__ 1

The build log:
----
[...]
/usr/share/clang/scan-build/c++-analyzer -c -pipe -O2 -Wall -W 
-D_REENTRANT -fPIC -DUTILS_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB 
-DQT_CORE_LIB -I/opt/lambda/2013.10/5.1.1/gcc/mkspecs/linux-g++ -I. 
-I/opt/lambda/2013.10/5.1.1/gcc/include 
-I/opt/lambda/2013.10/5.1.1/gcc/include/QtXml 
-I/opt/lambda/2013.10/5.1.1/gcc/include/QtCore -I. -o fileutils.o 
fileutils.cpp
In file included from qtcassert.cpp:30:
In file included from ./qtcassert.h:33:
In file included from ./utils_global.h:4:
/opt/lambda/2013.10/5.1.1/gcc/include/QtCore/qglobal.h:975:4: error: 
"You must build your code with position independent code if Qt was built 
with -reduce-relocations. "         "Compile your code with -fPIC or -fPIE."
#  error "You must build your code with position independent code if Qt 
was built with -reduce-relocations. "\
    ^
1 error generated.
[...]
----

And in qglobal.h:975
----
#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && 
defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
#  error "You must build your code with position independent code if Qt 
was built with -reduce-relocations. "\
          "Compile your code with -fPIC or -fPIE."
#endif
----



More information about the Development mailing list