title: Libm relocation error when building Qt 5 for Nitrogen6x
body: <p>I am trying to build Qt 5 on a <em>Nitrogen6x board</em> powered by an *i.MX6Q`.</p>
  
  <p>I've installed <em>Debian/wheezy</em> on the board and am using an <em>Ubuntu 12.10</em> machine for cross-compiling.</p>
  
  <p>Configuring Qt works like a charm but I am stuck in the make step.
  This is the configure script I run:</p>
  
  <pre><code>./configure -v -opensource -confirm-license  -reduce-relocations -no-pch -no-xcb -no-opengl -opengl es2  -qt-libpng -qt-zlib -qt-xkbcommon -qt-xcb -qt-pcre -qt-libjpeg -qt-sql-mysql -optimized-qmake\
     -make libs -device imx6 \
     -compile-examples   \
     -device-option CROSS_COMPILE=/home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabi- \
     -sysroot /media/finn/d72e3b65-b529-4e5c-9d30-872e1b0c9973 \
     -prefix /opt/qt5
  </code></pre>
  
  <p>And this is the error I receive about 5 minutes into the make process:</p>
  
  <pre><code>/home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: 
  /media/finn/d72e3b65-b529-4e5c-9d30-872e1b0c9973/usr/lib/libm.a(mpa.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
  /media/finn/d72e3b65-b529-4e5c-9d30-872e1b0c9973/usr/lib/libm.a: could not read symbols: Bad value
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I've run into the same error before, when it was trying to access libz.a but adding the qt-zlib parameter to the configure command fixed that issue.</p>
  
  <p>Many articles state that affected applications/libraries should be recompiled, however I don't think that's possible as libm is part of libc6.</p>
  
  <p>I already tried reinstalling it using <code>aptitude remove libc6-dev zlib1g-dev g++-4.6</code>
  and <code>apt-get install gcc g++ make flex bison openssl libssl-dev perl perl-base perl-modules libperl-dev build-essential</code></p>
  
  <p>Sadly this did not fix the problem.</p>
  
  <p>Debian has been installed using the official network installer as well as a Kernel and an Overlay provided by Boundarydevices, the manufacturer of the board.</p>
  
  <p>Does anyone has an idea how to fix this?</p>
  
  <p>My next step would be to install a completely new Debian system but I would really like to avoid that.</p>
  
  <h2>Edit</h2>
  
  <p>Compiling qtbase with -static option works for me, however I am running into this error when trying to build qtdeclarative during the make step:</p>
  
  <pre><code>    /home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
  /home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
  /home/finn/qt/qtbase/lib/libQt5Core.a(qlibrary_unix.o): In function `QLibraryPrivate::load_sys()':
  qlibrary_unix.cpp:(.text+0xaac): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqxcb
  /home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/arm-linux-gnueabihf/libpthread.so.0
  /home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/arm-linux-gnueabihf/libpthread_nonshared.a
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <h2>Edit 2 - Solution</h2>
  
  <p>I fixed the problem and successfully compiled Qt.
  All I needed to do was reinstall Ubuntu. It sure isn't an elegant solution but it works for me.</p>