Skipping incompatible /lib/libpthread.so.0 when searching for /lib/libpthread.so.0

By | January 5, 2018

This normally happens when compiling for an arch, say ARM, and try to execute the binary in an x86_64 arch.
But in this case, it was not this problem, I was sure that I was compiling and executing for the right places for the right archs.

The error was the following:

/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /lib/libpthread.so.0 when searching for /lib/libpthread.so.0
/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/libpthread.so.0

Then I discovered that the same issue appears with libc.so.6.
For some reason this happened after a Fedora upgrade, something got missing during the upgrade.

In order to fix it, change to the directory where your sysroot resides, in my case is /opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/sysroot

Edit the file usr/lib/libpthread.so.
Change the GROUP line that is where the linker searches for libpthread:

/*GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )*/
GROUP ( libpthread.so.0 libpthread_nonshared.a )

Edit also the file usr/lib/libc.so:

/*GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) )*/
GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux-armhf.so.3 ) )

After this, I was able again to execute the binaries as before.

Leave a Reply

Your email address will not be published. Required fields are marked *