(Cross compile) Como especificar a localização de bibliotecas para ld no Makefile?

0

Estou compilando pciutils (mas não é importante, poderia ser outro código-fonte) com uma versão ARC do gcc.

Quando eu compilo, o processo é interrompido porque não consegue encontrar as bibliotecas necessárias:

/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

Mas, por exemplo, crt1.o pode ser encontrado em três diretórios:

/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

Como posso evitar esse problema? Pode ser útil também para outros códigos-fonte (já que tenho que compilar alguns conjuntos de).

Obrigado.

    
por simozz 26.11.2015 / 09:51

1 resposta

1

Geralmente em makefiles você pode adicionar -L/path/to/lib aos sinalizadores de linker. No entanto, eu não sei se esta é uma boa solução para o seu problema concreto.

    
por 26.11.2015 / 10:23