设置全局gcc默认搜索路径

时间:2011-09-19 20:04:25

标签: gcc cross-compiling glibc codesourcery

运行时

arm-none-linux-gnueabi-gcc -print-search-dirs | grep libraries | sed 's/:/\n/g'

我得到以下输出:

libraries
 =/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/
/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.4.1/
/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib/
/opt/codesourcery/arm-none-linux-gnueabi/libc/lib/arm-none-linux-gnueabi/4.4.1/
/opt/codesourcery/arm-none-linux-gnueabi/libc/lib/
/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/arm-none-linux-gnueabi/4.4.1/
/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/

当交叉编译某些软件包时,它会使我的生活更容易附加到这些路径。我知道-L选项,我想使用它,但许多软件包在交叉编译时不尊重它,而且使用它与代码源会导致问题。 (有关详细信息,请参阅本文末尾)。基本上我有一个完整的目录树,其中包含编译包所需的所有文件,我想将该目录树添加到默认搜索路径中。例如,-print-search-dirs也将输出类似于:

的路径
/target/usr/lib
/target/lib

除已列出的路径外。我不是在寻找一个具有代码性的特定答案,因为我有几个可以使用的工具链。

对于那些好奇的人,这是代码源安装的错误:

arm-none-linux-gnueabi-gcc test.c

作品

arm-none-linux-gnueabi-gcc -L/usr/arm-unknown-linux-gnueabi/usr/lib test.c 

失败了:

/lib/libc.so.6: file not recognized: File format not recognized
collect2: ld returned 1 exit status
显然它正在从主机那里抓取libc。我已经看到这种情况发生在一个以上的工具链上,但不是全部。

回复评论: 这是

的输出
arm-none-linux-gnueabi-gcc -L/usr/arm-unknown-linux-gnueabi/usr/lib test.c -v -Wl,-verbose
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/2010q1-release-linux-lite/src/gcc-4.4-2010q1/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2010q1-202' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) 
COLLECT_GCC_OPTIONS='-L/usr/arm-unknown-linux-gnueabi/usr/lib' '-v' '-march=armv5te' '-funwind-tables'
 /opt/codesourcery/libexec/gcc/arm-none-linux-gnueabi/4.4.1/cc1 -quiet -v test.c -quiet -dumpbase test.c -march=armv5te -auxbase test -version -funwind-tables -o /tmp/ccaDSo09.s
ignoring nonexistent directory "/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/local/include"
#include "..." search starts here:
#include  search starts here:
 /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/include
 /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/include-fixed
 /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/include
 /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/include
End of search list.
GNU C (Sourcery G++ Lite 2010q1-202) version 4.4.1 (arm-none-linux-gnueabi)
        compiled by GNU C version 4.3.2, GMP version 4.3.1, MPFR version 2.4.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 250bf78701f747da89e730786c466148
COLLECT_GCC_OPTIONS='-L/usr/arm-unknown-linux-gnueabi/usr/lib' '-v' '-march=armv5te' '-funwind-tables'
 /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/as -v -march=armv5te -meabi=5 -o /tmp/ccQTJKJd.o /tmp/ccaDSo09.s
GNU assembler version 2.19.51 (arm-none-linux-gnueabi) using BFD version (Sourcery G++ Lite 2010q1-202) 2.19.51.20090709
COMPILER_PATH=/opt/codesourcery/libexec/gcc/arm-none-linux-gnueabi/4.4.1/:/opt/codesourcery/libexec/gcc/arm-none-linux-gnueabi/4.4.1/:/opt/codesourcery/libexec/gcc/arm-none-linux-gnueabi/:/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/:/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/:/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/
LIBRARY_PATH=/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/:/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib/:/opt/codesourcery/arm-none-linux-gnueabi/libc/lib/:/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/
COLLECT_GCC_OPTIONS='-L/usr/arm-unknown-linux-gnueabi/usr/lib' '-v' '-march=armv5te' '-funwind-tables'
 /opt/codesourcery/libexec/gcc/arm-none-linux-gnueabi/4.4.1/collect2 --sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crt1.o /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crti.o /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/crtbegin.o -L/usr/arm-unknown-linux-gnueabi/usr/lib -L/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1 -L/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib -L/opt/codesourcery/arm-none-linux-gnueabi/libc/lib -L/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib /tmp/ccQTJKJd.o -verbose -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/crtend.o /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crtn.o
GNU ld (Sourcery G++ Lite 2010q1-202) 2.19.51.20090709
  Supported emulations:
   armelf_linux_eabi
   armelfb_linux_eabi
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
              "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00008000)); . = SEGMENT_START("text-segment", 0x00008000) + SIZEOF_HEADERS;
  .interp         : { *(.interp) }
  .note.gnu.build-id : { *(.note.gnu.build-id) }
  .hash           : { *(.hash) }
  .gnu.hash       : { *(.gnu.hash) }
  .dynsym         : { *(.dynsym) }
  .dynstr         : { *(.dynstr) }
  .gnu.version    : { *(.gnu.version) }
  .gnu.version_d  : { *(.gnu.version_d) }
  .gnu.version_r  : { *(.gnu.version_r) }
  .rel.dyn        :
    {
      *(.rel.init)
      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
      *(.rel.fini)
      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
      *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
      *(.rel.ctors)
      *(.rel.dtors)
      *(.rel.got)
      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
      *(.rel.ifunc)
    }
  .rela.dyn       :
    {
      *(.rela.init)
      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
      *(.rela.fini)
      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
      *(.rela.ctors)
      *(.rela.dtors)
      *(.rela.got)
      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
      *(.rela.ifunc)
    }
  .rel.plt        :
    {
      *(.rel.plt)
      PROVIDE_HIDDEN (__rel_iplt_start = .);
      *(.rel.iplt)
      PROVIDE_HIDDEN (__rel_iplt_end = .);
    }
  .rela.plt       :
    {
      *(.rela.plt)
      PROVIDE_HIDDEN (__rela_iplt_start = .);
      *(.rela.iplt)
      PROVIDE_HIDDEN (__rela_iplt_end = .);
    }
  .init           :
  {
    KEEP (*(.init))
  } =0
  .plt            : { *(.plt) *(.iplt)}
  .text           :
  {
    *(.text .stub .text.* .gnu.linkonce.t.*)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
  } =0
  .fini           :
  {
    KEEP (*(.fini))
  } =0
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  .rodata1        : { *(.rodata1) }
  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
   PROVIDE_HIDDEN (__exidx_start = .);
  .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
   PROVIDE_HIDDEN (__exidx_end = .);
  .eh_frame_hdr : { *(.eh_frame_hdr) }
  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  /* Exception handling  */
  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  /* Thread Local Storage sections  */
  .tdata          : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  }
  .init_array     :
  {
     PROVIDE_HIDDEN (__init_array_start = .);
     KEEP (*(SORT(.init_array.*)))
     KEEP (*(.init_array))
     PROVIDE_HIDDEN (__init_array_end = .);
  }
  .fini_array     :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array))
    PROVIDE_HIDDEN (__fini_array_end = .);
  }
  .ctors          :
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin.o(.ctors))
    KEEP (*crtbegin?.o(.ctors))
    /* We don't want to include the .ctor section from
       the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }
  .dtors          :
  {
    KEEP (*crtbegin.o(.dtors))
    KEEP (*crtbegin?.o(.dtors))
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
    KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
  }
  .jcr            : { KEEP (*(.jcr)) }
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
  .dynamic        : { *(.dynamic) }
  . = DATA_SEGMENT_RELRO_END (0, .);
  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
  .data           :
  {
    __data_start = . ;
    *(.data .data.* .gnu.linkonce.d.*)
    SORT(CONSTRUCTORS)
  }
  .data1          : { *(.data1) }
  _edata = .; PROVIDE (edata = .);
  __bss_start = .;
  __bss_start__ = .;
  .bss            :
  {
   *(.dynbss)
   *(.bss .bss.* .gnu.linkonce.b.*)
   *(COMMON)
   /* Align here to ensure that the .bss section occupies space up to
      _end.  Align after .bss to ensure correct alignment even if the
      .bss section disappears because there are no input sections.
      FIXME: Why do we need it? When there is no .bss section, we don't
      pad the .data section.  */
   . = ALIGN(. != 0 ? 32 / 8 : 1);
  }
  _bss_end__ = . ; __bss_end__ = . ;
  . = ALIGN(32 / 8);
  . = ALIGN(32 / 8);
  __end__ = . ;
  _end = .; PROVIDE (end = .);
  . = DATA_SEGMENT_END (.);
  /* Stabs debugging sections.  */
  .stab          0 : { *(.stab) }
  .stabstr       0 : { *(.stabstr) }
  .stab.excl     0 : { *(.stab.excl) }
  .stab.exclstr  0 : { *(.stab.exclstr) }
  .stab.index    0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment       0 : { *(.comment) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /* DWARF 3 */
  .debug_pubtypes 0 : { *(.debug_pubtypes) }
  .debug_ranges   0 : { *(.debug_ranges) }
  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
}


==================================================
attempt to open /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crt1.o succeeded
/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crt1.o
attempt to open /opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crti.o succeeded
/opt/codesourcery/arm-none-linux-gnueabi/libc/usr/lib/crti.o
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/crtbegin.o succeeded
/opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/crtbegin.o
attempt to open /tmp/ccQTJKJd.o succeeded
/tmp/ccQTJKJd.o
attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libgcc.so failed
attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libgcc.a failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/libgcc.so failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/libgcc.a succeeded
attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libgcc_s.so failed
attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libgcc_s.a failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/libgcc_s.so failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/libgcc_s.a failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib/libgcc_s.so failed
attempt to open /opt/codesourcery/lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/lib/libgcc_s.a failed
attempt to open /opt/codesourcery/arm-none-linux-gnueabi/libc/lib/libgcc_s.so succeeded
-lgcc_s (/opt/codesourcery/arm-none-linux-gnueabi/libc/lib/libgcc_s.so)
attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libc.so succeeded
opened script file /usr/arm-unknown-linux-gnueabi/usr/lib/libc.so
opened script file /usr/arm-unknown-linux-gnueabi/usr/lib/libc.so
attempt to open /lib/libc.so.6 succeeded
opened script file /lib/libc.so.6
/lib/libc.so.6: file not recognized: File format not recognized
collect2: ld returned 1 exit status

2 个答案:

答案 0 :(得分:12)

您的交叉编译glibc配置错误。

-Wl,-verbose链接器中说:

attempt to open /usr/arm-unknown-linux-gnueabi/usr/lib/libc.so succeeded
opened script file /usr/arm-unknown-linux-gnueabi/usr/lib/libc.so

因此,它使用了您的-L选项,并且能够打开libc.so.但这不是一个真正的.so动态库,它是一个脚本(链接器脚本)。

Telepathic模式开启:此libc.so脚本的最后一行是

 GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.3 ) )

关闭心灵感应模式

此行包含硬编码的绝对路径,并将arm -... abi中的链接器重定向到系统的libc,忽略大多数搜索目标(可能存在ld的某些秘密选项。)

只需使用任何文本编辑器编辑此文件(进行备份),并将所有/lib替换为/usr/arm-unknown-linux-gnueabi/lib。 (我的良好的交叉编译环境已将此脚本中的所有路径替换为前缀。)

原始脚本应该用于本机编译,本机运行,但不能用于交叉编译。

更新:bytesex说http://linux.bytesex.org/cross-compiler.html /usr/lib/libpthread.so存在同样的问题,也在此文件中进行替换。

要检查其他库,请在lib目录中执行file -skL *.so|grep text

答案 1 :(得分:6)

As explained by @osgx,gcc正在寻找其库的错误路径。我试图在x86_64上交叉编译arm程序时遇到了类似的问题。由于编辑根拥有的文件不是一个选项,我进一步搜索并发现了--sysroot选项:

  

- SYSROOT = DIR
  使用dir作为标头和库的逻辑根目录。例如,如果编译器通常在/ usr / include和/ usr / lib中的库中搜索头文件,则会搜索dir / usr / include和dir / usr / lib。

     

如果同时使用此选项和-isysroot选项,则--sysroot选项适用于库,但-isysroot选项适用于头文件。

     

GNU链接器(从版本2.16开始)具有对此选项的必要支持。如果您的链接器不支持此选项,则--sysroot的头文件方面仍然有效,但库方面没有。

使用示例:

./configure --host=arm-unknown-linux-gnueabi \
    CFLAGS='-g -O2 --sysroot=/tmp/rpi-root'