Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crosstools-ng can't find pthread.so

I am trying to use crosstools-ng to compile a program that uses pthread, however for some reason the linker can't find the library. I have checked and the libraries are located in the link path specificed by -L is the arguments.

Here is the error:

/home/***/raspberrypi/toolchain/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/../../../.. /arm-unknown-linux-gnueabi/bin/ld: cannot find /lib/arm-linux-gnueabihf/libpthread.so.0

/home/***/raspberrypi/toolchain/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/../../../../arm-unknown-linux-gnueabi/bin/ld: cannot find /usr/lib/arm-linux-gnueabihf/libpthread_nonshared.a

Why can't ld find the file that is within the path?

like image 999
John Avatar asked Jan 08 '13 02:01

John


2 Answers

Edit your .../usr/lib/arm-linux-gnueabihf/libpthread.so:

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/arm-linux-gnueabihf/libpthread.so.0 /usr/lib/arm-linux-gnueabihf/libpthread_nonshared.a )

to

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libpthread.so.0 libpthread_nonshared.a )
like image 123
user2675643 Avatar answered Sep 29 '22 18:09

user2675643


See this info page: https://sourceware.org/binutils/docs-2.24/ld/File-Commands.html#File-Commands

Read the definitions of INPUT and GROUP, specifically:

In case a sysroot prefix is configured, and the filename starts with the `/' character, and the script being processed was located inside the sysroot prefix, the filename will be looked for in the sysroot prefix. Otherwise, the linker will try to open the file in the current directory. If it is not found, the linker will search through the archive library search path. See the description of `-L' in Command Line Options.

So your linker script should be:

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )

...as your toolchain is using a sysroot prefix.

You can find your sysroot prefix with:

<tuple>-gcc -print-sysroot
like image 36
bhundven Avatar answered Sep 29 '22 18:09

bhundven