Hi,Laurentiu I think it could be something wrong with binutils(2.23.1 or later) there is different behavior at binutils-2.23.1/ld/ldfile.c(ldfile_open_file_search) from binutils-2.22
If both --sysroot directory and -L directory include libc.so , ld don't work In my case, there are double libc.so(/yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-poky-linux/usr/lib/libc.so and tmp/sysroots/qemux86-64/usr/lib/libc.so) ld will link tmp/sysroots/qemux86-64/usr/lib/libc.so(ld always searchs -L directory at first) then link /lib/libc.so.6 specified at tmp/sysroots/qemux86-64/usr/lib/libc.so instead of append sysroot directory path before /lib/libc.so.6 here is a sample method reproduce it lizj@suika x86-64-yocto-1.3]$ source toolchain-1.3-tcmode-default/environment-setup-x86_64-poky-linux [lizj@suika x86-64-yocto-1.3]$ echo $CC x86_64-poky-linux-gcc -m64 --sysroot=/yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-poky-linux [lizj@suika x86-64-yocto-1.3]$ $LD --version GNU ld (GNU Binutils) 2.23.1.20121113 [lizj@suika x86-64-yocto-1.3]$ mkdir -p fake_rootfs/usr/lib [lizj@suika x86-64-yocto-1.3]$ cp /yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-poky-linux/usr/lib/libc.so fake_rootfs/usr/lib/ [lizj@suika x86-64-yocto-1.3]$ ls fake_rootfs/usr/lib/ libc.so [lizj@suika x86-64-yocto-1.3]$ $CC -o test test.c -L ./fake_rootfs/usr/lib/ test.c: In function 'main': test.c:3:9: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default] /yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/../../libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/4.7.2/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6 /yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/../../libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/4.7.2/ld: cannot find /lib/libc.so.6 /yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/../../libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/4.7.2/ld: skipping incompatible /usr/lib/libc_nonshared.a when searching for /usr/lib/libc_nonshared.a /yocto/fnst/lizj/build_yocto/x86-64-yocto-1.3/toolchain-1.3-tcmode-default/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/../../libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/4.7.2/ld: cannot find /usr/lib/libc_nonshared.a collect2: error: ld returned 1 exit status ------------------------------------------------------------------------- It seems that ld don‘t really reasonable to do like that,which binutils-2.22 can handle correctly Does poky mind this behavior 以上 -- Best regards. Li Zhijian at 2013-9-20 19:00, Laurentiu Palcu wrote:
Hi, On Fri, Sep 20, 2013 at 06:25:19PM +0800, Li Zhijian wrote:III) compile a simple C program # cat test.c int main () { printf("hello world\n"); return 0; } # source toolchain-1.3-tcmode-default/environment-setup-x86_64-poky-linux # $CC -o test test.c -L tmp/sysroots/qemux86-64/usr/lib/ -lmOK, it looks like something strange happens in your setup. To debug it, let's add '-Wl,--verbose' at the end of your command and you should be able to see where the linker is looking for libraries. Also, the linker script will be printed. You should see it try your directory first tmp/sysroots/qemux86-64/usr/lib/, and then fall through the default ones with the sysroot prefix added and, at the end, the system ones: /lib:/usr/lib. Thanks, Laurentiu
_______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto
