zoukankan      html  css  js  c++  java
  • gcc include路径

    《GCC:the complete referrence》说,gcc的include有以下几个组成:

    On a UNIX system, the standard set of system directories is as follows:
    /usr/local/include
    /usr/lib/gcc-lib/target/version/include
    /usr/target/include
    /usr/include

    通过 gcc -v   *.c 可以看编译时具体过程:
    [hyang0@pek-wb-auto ~]$ gcc -v hello.c 
    Using built-in specs.
    Target: i386-redhat-linux
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
    Thread model: posix
    gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)
    /usr/libexec/gcc/i386-redhat-linux/4.1.1/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/ccPUf6Jg.s
    ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/http://www.cnblogs.com/i386-redhat-linux/include"
    #include "..." search starts here:
    #include <...> search starts here:
    /usr/local/include
    /usr/lib/gcc/i386-redhat-linux/4.1.1/include
    /usr/include
    End of search list.

    GNU C version 4.1.1 20070105 (Red Hat 4.1.1-52) (i386-redhat-linux)
    compiled by GNU C version 4.1.1 20070105 (Red Hat 4.1.1-52).
    GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=129176
    Compiler executable checksum: 92efef273c2911dfe2bff20f05a618b3
    as -V -Qy -o /tmp/ccEed4Cr.o /tmp/ccPUf6Jg.s
    GNU assembler version 2.17.50.0.6-2.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-2.el5 20061020
    /usr/libexec/gcc/i386-redhat-linux/4.1.1/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.1/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.1 -L/usr/lib/gcc/i386-redhat-linux/4.1.1 -L/usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/.. /tmp/ccEed4Cr.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.1/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crtn.o
    [hyang0@pek-wb-auto ~]$

    可以看到search过程:
    #include "..." search starts here:
    #include <...> search starts here:
    /usr/local/include
    /usr/lib/gcc/i386-redhat-linux/4.1.1/include
    /usr/include
    End of search list.

    如果要添加查找路径:
    The following is a list of the environment variables that can be set to pass instructions
    to the preprocessor.

    C_INCLUDE_PATH, CPATH, CPLUS_INCLUDE_PATH, DEPENDENCIES_OUTPUT,
    OBJC_INCLUDE_PATH, SUNPRO_DEPENDENCIES

    对所有用户有效在/etc/profile增加以下内容。只对当前用户有效在Home目录下的
    .bashrc或.bash_profile里增加下面的内容:
    (注意:等号前面不要加空格,否则可能出现 command not found)

    #在PATH中找到可执行文件程序的路径。
    export PATH =$PATH:$HOME/bin

    #gcc找到头文件的路径
    C_INCLUDE_PATH=/usr/include/libxml2:/MyLib
    export C_INCLUDE_PATH

    #g++找到头文件的路径
    CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/libxml2:/MyLib
    export CPLUS_INCLUDE_PATH

    #找到动态链接库的路径
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/MyLib
    export LD_LIBRARY_PATH

    #找到静态库的路径
    LIBRARY_PATH=$LIBRARY_PATH:/MyLib
    export LIBRARY_PATH

     

    连接器ld搜索路径和顺序
    bash$  ld --verbose | grep SEARCH
    SEARCH_DIR("/usr/i486-linux-gnu/lib32"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i486-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
    bash$ 

  • 相关阅读:
    SQL2008-显示表大小行数
    SQL2008-备份SQL数据库的语句
    SQL2008-截取字段函数
    SQL2008-字符转数字CAST和CONVERT
    SQL2008-查询库中是否存在某表
    SQLServer 2000个人版下载
    SQL2008-不同数据库之间的触发器
    SQL2008--行号的得到
    Microsoft Visual Stduio 2005 Ent安装报错解决方法
    zlib快速编译脚本
  • 原文地址:https://www.cnblogs.com/daoxuebao/p/2466016.html
Copyright © 2011-2022 走看看