交叉工具链在编译应用程序时,如何查找默认的头文件路径

Posted zhengaloha

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了交叉工具链在编译应用程序时,如何查找默认的头文件路径相关的知识,希望对你有一定的参考价值。

默认的搜索路径是通过在ubuntu-12.04的shell窗口输入如下命令显示:

echo ‘main(){}‘|arm-linux-gcc -E -v - 
  • 1

比如说我的路径显示则如下:

Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/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 --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion=‘Sourcery G++ Lite 2008q3-72‘ --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/lite-respin/linux/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) 
COLLECT_GCC_OPTIONS=‘-march=armv4t‘ ‘-E‘ ‘-v‘
 /usr/local/arm-4.3.2/4.3.2/bin/../libexec/gcc/arm-none-linux-gnueabi/4.3.2/cc1 -E -quiet -v -imultilib armv4t -iprefix /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/ -isysroot /usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc - -march=armv4t
ignoring nonexistent directory "/usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/local/include"
ignoring duplicate directory "/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.2/include"
ignoring duplicate directory "/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed"
ignoring duplicate directory "/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/include
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/include
 /usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
main(){}
COMPILER_PATH=/usr/local/arm-4.3.2/4.3.2/bin/../libexec/gcc/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm-4.3.2/4.3.2/bin/../libexec/gcc/:/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/
LIBRARY_PATH=/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/lib/armv4t/:/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/:/usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/lib/:/usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc/armv4t/lib/:/usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc/armv4t/usr/lib/
COLLECT_GCC_OPTIONS=‘-march=armv4t‘ ‘-E‘ ‘-v‘
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

其中的下面这一段就代表着arm-linux-gcc在编译文件时所搜索的头文件路径:

#include "..." search starts here:
#include <...> search starts here:
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/include
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed
 /usr/local/arm-4.3.2/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/include
 /usr/local/arm-4.3.2/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include

库文件搜索路径:

LIBRARY_PATH=/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/lib/armv4t/:/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/../lib/gcc/:/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/lib/:/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/armv4t/lib/:/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/armv4t/usr/lib/



海思平台的交叉工具链的搜索路径

#include <...> search starts here:
/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/include
/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/include-fixed
/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/include
/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../target/usr/include

 

库文件搜索路径 

COMPILER_PATH=/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../libexec/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../libexec/gcc/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/bin/
LIBRARY_PATH=/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../target/lib/:/opt/hisi-linux-nptl/arm-hisiv100-linux/bin/../target/usr/lib/

 
















以上是关于交叉工具链在编译应用程序时,如何查找默认的头文件路径的主要内容,如果未能解决你的问题,请参考以下文章

2019年7月18日星期四(交叉工具链)

arm-linux-gcc工具链:汇编文件如何include c的头文件呢???

使用跨工具链在 Linux 上构建软件

linux 头文件 位置

Linux From Scratch(LFS11.0)交叉编译临时工具 - Findutils-4.8.0

arm-linux-gcc怎么编译自己写的头文件