Tag Archives: libpthread

Linker “ld: cannot find /lib/libpthread.so.0″

Having frustrated using Scratchbox to compile my module code for ARM device, I decided to switch to cross-compilation in Desktop for ARM target. I feel scratchbox is one of the most stupidest, difficult to use, good-for-nothing software, which serves nothing better than what cross compiler toolchains can do. And the worst part is, if you do not have admin rights at the host system where scratchbox is installed, then it means, you can not install and use your favourate softwares, like emacs, git!! Stealing your freedom?, definately not a good deal!. Right?

Well, next task was to setup the cross-compilation environment, in my host x86 machine, using appropriate toolchains, with the aid of gcc’s –sysroot option. I managed to write a small script to cross-compile my code using scratchbox-toolchain-arm-linux-cs2010q1-202 cross compiler (http://www.scratchbox.org/download/files/sbox-releases/hathor/tarball/). Compilation went through fine, however, while linking my module, linker thowed below error, even though I made sure all paths are properly set,

/opt/compilers/arm-linux-cs2010q1-202/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /lib/libpthread.so.0 when searching for /lib/libpthread.so.0
/opt/compilers/arm-linux-cs2010q1-202/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find /lib/libpthread.so.0

It seems like linker is searching for “/lib/libpthread.so.0″ instead of plain “libpthread.so.0″. After scratching head for hours and googling, I figured the cause for this error. The linker script at libc/usr/lib/libpthread.so has the following grouping,

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

And so this is where the /lib/libpthread.so.0 path is coming from. Modifiying the above line and removing the path information, like below,

GROUP ( libpthread.so.0 libpthread_nonshared.a )

linking just happened perfectly fine! Best part is, the compilation happens much faster now. Also I am able to use all my native sotwares freely. I got my “freedom” back. :)