linux header file loading sequence

Refer to the header file search path under Linux

“header.h”

 #include "header.h"

When the same file exists in each directory, first find which one to use. The loading sequence is as follows:

  1. Current directory

  2. The directory specified by the parameter -I when gcc is compiled

  3. Environment variable C_INCLUDE_PATH (C++ uses CPLUS_INCLUDE_PATH)

  4. System default directory

    • /usr/include
    • /usr/local/include
    • /usr/include/x86_64-linux-gnu

<header.h>

#include <header.h>

When the same file exists in each directory, first find which one to use. But the current directory will not be searched !

  1. The directory specified by the parameter -I when gcc is compiled

  2. Environment variable C_INCLUDE_PATH (C++ uses CPLUS_INCLUDE_PATH)

  3. System default directory

    • /usr/include
    • /usr/local/include
    • /usr/include/x86_64-linux-gnu

You can view the LIBRARY_PATH and INCLUDE paths of gcc through the following command

echo 'main(){}' | gcc -E -v -

Guess you like

Origin blog.csdn.net/weixin_43742643/article/details/113814745