(交叉编译)如何在Makefile中指定ld的库位置?

(交叉编译)如何在Makefile中指定ld的库位置?

我正在使用 gcc ARM 版本编译 pciutils(但这并不重要,它可能是另一个源代码)。

当我编译时,进程停止,因为它找不到所需的库:

/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crt1.o: No such file or directory
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crti.o: No such file or directory
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtbegin.o: No such file or directory
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lz
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lresolv
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc_s
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lc
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc_s
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtend.o: No such file or directory
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/i686-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
Makefile:103: recipe for target 'lspci' failed
make: *** [lspci] Error 1

但是,例如,crt1.o可以在三个目录中找到:

/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/overo-tcbootstrap/usr/lib/crt1.o
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/overo/usr/lib/crt1.o
/home/simo/development/gcc-armhf-yocto-sysroot/sysroots/overo/usr/include/glibc-locale-internal-cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/lib/crt1.o

我怎样才能避免这个问题?它对于其他源代码也很有用(因为我必须编译几组)。

谢谢。

答案1

通常,您可以在 makefile 中添加-L/path/to/lib链接器标志。但是我不知道这对于您的具体问题是否是一个好的解决方案。

相关内容