I’ve trying to cross compile an app for iMX6 CPU using linaro-gcc and a dedicated rootfs. The app might be linked to OpenVG and the standard pthread libraries.
It compiles fine but the linker failed to link to the OpenVG library so I added the linker switch -L/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/usr/lib and now it links to the OpenVG library. But since then, it can’t link to pthread library even with the linker swtich -L/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/lib.
The error message is :
../arm-linux-gnueabihf/bin/ld: cannot find /lib/libpthread.so.0 ../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/libpthread_nonshared.a
Those libraries are in the /home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/lib directory.
Here’s the LDFLAGS var.
LDFLAGS = -lpthread -lOpenVG -L/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/lib -L/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/usr/lib
Does anyone know why ld can’t link to those libraries even if I added the -L switch to tell it where to find them?
edit April 30, 2015 at 16:55
I used strace to find what’s going on… I don’t know what’s going on but it tries to open libpthread.so in several dirs even in the right ones but it does not link with it.
Here’s the output.
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 open("/lib/i386-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 open("/lib/i386-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 open("/lib/i386-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 open("/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/lib/libpthread.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/lib/libpthread.a", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/usr/lib/libpthread.so", O_RDONLY|O_LARGEFILE) = 3 open("/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/usr/lib/libpthread.so", O_RDONLY) = 4 open("/home/ae/Documents/toradex/col-imx6/colibri-imx6-sdk/usr/lib/libpthread.so", O_RDONLY) = 3 open("/lib/libpthread.so.0", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/libpthread_nonshared.a", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
Advertisement
Answer
I fixed this issue using the compiler and linker switch –sysroot so the linker and the compiler both work using the arm rootfs as base directory.