(크로스 컴파일) 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링커 플래그를 추가합니다. 그러나 이것이 귀하의 특정 문제에 대한 좋은 해결책인지는 모르겠습니다.

관련 정보