Building qt-4.8.4 link error.
I was building qt-4.8.4 from source on a linux-from-scratch distribution and noticed that there were some problems with the build system when configured for linux x86 using g++ 4.5.1 compiler.
First problem: build system could not link objects because some parameters in LDFLAGS were set to, for example: -Wl,-rpath-link,/some/path -Wl,-rpath,/some/path -Wl,-O1 . These parameters should be set to: -rpath-link /some/path -rpath /some/path -O1. One way that I fixed this was to overwrite the default linker to g++ compiler, since all the linker's parameters were written as if they are for the compiler. Running: "make QMAKE_LINK=g++" allowed me to overwrite the linker, and it worked.
I also made the following changes to the configure script because before using qmake, the build system still uses ld linker to build basic tools/utils. Here was the patch:
--- configure.vanilla 2013-04-23 12:25:37.000000000 -0400
+++ configure 2013-04-23 13:33:35.000000000 -0400
Because qt is broken, toan
compilerSupportsFlag $compiler $lflags >/dev/null 2>&1
I also added the following config parameters to the linker's flag, but I do not remember where. The added linker's flag was:
-lstdc++ -lc -lLTO -fPIC -shared
without libstdc++, it wouldn't link. libLTO was included b/c qt needed to link with "__dso_handle". "-fPIC -shared" because we may link to generate a shared library, for example, libbootstrap.so
To replicate the issue, compilation was configured and built with the following commands
./configure -prefix /opt/qt4 -bindir //opt/qt4/bin -libdir //opt/qt4/lib -system-zlib -system-libmng -system-libpng -system-libjpeg -xrender -xmlpatterns -plugin-sql-mysql -no-gif -no-separate-debug-info -fast -opensource
eval make $makeopt LD=g++ QMAKE_LINK=g++ -j8
where makeopt = CC="$CC" CPP="$CPP" CXX="$CXX" prefix="/$prefix" docdir="$docdir"
I hope to share this to get feedback on why qt-builder was done that way. In addition, i do not want another person has to apply similar patches to compile QT-4.8.4
Just update your gcc. 4.8.4 need the newer version of compiler.... Can build QT on my LFS without any problem...
I found the root of the qt link error, that was described above. The error can also be found on <=qt-5.0.2 (last version i tested).
If one is building QT 4 or 5 and having an environment variable LD=ld or LD=arm-linux-ld, for example, QT build tool then would revert to using the "ld" linker while still using clfags (at link time), instead of using the proper lflags. I think this is a bug in the build system. To circumvent this bug, be sure to set global environment variable LD=g++
Or else, apply the patch above.