头文件路径

gcc 在编译时寻找所需要的头文件 :
  
※搜寻会从-I开始
  
※然后找gcc的环境变量 C_INCLUDE_PATH,CPLUS_INCLUDE_PATH,OBJC_INCLUDE_PATH
  
※再找内定 目录

/usr/include

 

1. linux编译C语言的内定 头文件目录内定目录
/usr/include

 

2. ubuntu的头文件需要到PATH下面去寻找,如果找不到会报: error: stdio.h: No such file or directory

a. 没有指定名称的头文件 stdio.h

root@romulus-laptop:/work/android/froyo# echo $PATH
/usr/lib/ccache:/root/Downloads/jdk1.5.0_22/bin:/root/Downloads/jdk1.5.0_22/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/eclipse:/work/android/froyo_stk/out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86/platform-tools:/work/android/froyo_stk/out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86/tools:/root/Downloads/arm-2010.09/bin

/usr不在PATH中呀?

root@romulus-laptop:/work/android/froyo# pwd
/work/android/froyo
root@romulus-laptop:/work/android/froyo# cat test.c
#include<stdio.h>
int main(void) {

    printf("hello world./n");
    return 0;
}

root@romulus-laptop:/work/android/froyo# locate stdio.h
/root/Downloads/arm-2010.09/arm-none-linux-gnueabi/include/c++/4.5.1/tr1/stdio.h
/root/Downloads/arm-2010.09/arm-none-linux-gnueabi/libc/usr/include/stdio.h
/root/Downloads/arm-2010.09/arm-none-linux-gnueabi/libc/usr/include/bits/stdio.h
/usr/include/stdio.h

root@romulus-laptop:/work/android/froyo# mv  /usr/include/stdio.h /usr/include/stdio.h_bake
root@romulus-laptop:/work/android/froyo# gcc -o test *.c
test.c:1:18: error: stdio.h: No such file or directory
test.c: In function ‘main’:
test.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
root@romulus-laptop:/work/android/froyo# mv  /usr/include/stdio.h_bake /usr/include/stdio.h
root@romulus-laptop:/work/android/froyo# gcc -o test *.c
root@romulus-laptop:/work/android/froyo# ./test
hello world.

 

你可能感兴趣的:(function,File,gcc,Path,include,2010)